• 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();

  • 相关阅读:
    Gist
    Gist
    Gist
    汉字编码与其16进制对照
    Horizon组件安装详解
    Github目录生成器
    MVC模式网站编写经验总结
    Java多线程小结
    JGit与远程仓库链接使用的两种验证方式(ssh和https)
    Peterson算法与Dekker算法解析
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/10957257.html
Copyright © 2020-2023  润新知