zoukankan      html  css  js  c++  java
  • NX二次开发-UFUN已知两个向量方向求夹角角度UF_VEC3_angle_between

     1     NX9+VS2012
     2 
     3     #include <uf.h>
     4     #include <uf_ui.h>
     5     #include <uf_vec.h>
     6     #include <uf_curve.h>
     7 
     8 
     9     UF_initialize();
    10 
    11     //创建直线1
    12     UF_CURVE_line_t LineCoords1;
    13     LineCoords1.start_point[0] = 0.0;
    14     LineCoords1.start_point[1] = 0.0;
    15     LineCoords1.start_point[2] = 0.0;
    16     LineCoords1.end_point[0] = 0.0;
    17     LineCoords1.end_point[1] = 100.0;
    18     LineCoords1.end_point[2] = 0.0;
    19     tag_t Line1Tag = NULL_TAG;
    20     UF_CURVE_create_line(&LineCoords1, &Line1Tag);
    21 
    22     //创建直线2
    23     UF_CURVE_line_t LineCoords2;
    24     LineCoords2.start_point[0] = 0.0;
    25     LineCoords2.start_point[1] = 0.0;
    26     LineCoords2.start_point[2] = 0.0;
    27     LineCoords2.end_point[0] = 110.0;
    28     LineCoords2.end_point[1] = 80.0;
    29     LineCoords2.end_point[2] = 0.0;
    30     tag_t Line2Tag = NULL_TAG;
    31     UF_CURVE_create_line(&LineCoords2, &Line2Tag);
    32 
    33     //直线1的向量方向,终点减起点
    34     double Vec1[3] = {LineCoords1.end_point[0]-LineCoords1.start_point[0], LineCoords1.end_point[1]-LineCoords1.start_point[1], LineCoords1.end_point[2]-LineCoords1.start_point[2]};
    35 
    36     //直线2的向量方向,终点减起点
    37     double Vec2[3] = {LineCoords2.end_point[0]-LineCoords2.start_point[0], LineCoords2.end_point[1]-LineCoords2.start_point[1], LineCoords2.end_point[2]-LineCoords2.start_point[2]};
    38 
    39     //求两个向量的叉乘
    40     double CrossProduct[3];
    41     UF_VEC3_cross(Vec1, Vec2, CrossProduct);
    42 
    43     //已知两个向量求夹角(输出的是弧度)
    44     double Angle;
    45     UF_VEC3_angle_between(Vec1, Vec2, CrossProduct, &Angle);
    46 
    47     //打印
    48     char msg[256];
    49     sprintf(msg, "%f",RADEG*Angle );//角度=180度/π*弧度,或者用宏定义RADEG*弧度
    50     uc1601(msg, 1);
    51 
    52     UF_terminate();

  • 相关阅读:
    C++ 引用详解
    QT的UDP组播技术
    idea快捷键
    window10安装不同版本的mysql(5.7和8.0.25)
    第2篇scrum
    结对项目:四则运算(C语言)
    个人项目wc(C语言)
    修改博客园背景,css
    第一次作业
    第4篇 Scrum 冲刺博客(专✌️团队)
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/10957257.html
Copyright © 2011-2022 走看看