NX9+VS2012

     #include <uf.h>
#include <uf_ui.h>
#include <uf_vec.h>
#include <uf_curve.h> UF_initialize(); //创建直线1
UF_CURVE_line_t LineCoords1;
LineCoords1.start_point[] = 0.0;
LineCoords1.start_point[] = 0.0;
LineCoords1.start_point[] = 0.0;
LineCoords1.end_point[] = 0.0;
LineCoords1.end_point[] = 100.0;
LineCoords1.end_point[] = 0.0;
tag_t Line1Tag = NULL_TAG;
UF_CURVE_create_line(&LineCoords1, &Line1Tag); //创建直线2
UF_CURVE_line_t LineCoords2;
LineCoords2.start_point[] = 0.0;
LineCoords2.start_point[] = 0.0;
LineCoords2.start_point[] = 0.0;
LineCoords2.end_point[] = 110.0;
LineCoords2.end_point[] = 80.0;
LineCoords2.end_point[] = 0.0;
tag_t Line2Tag = NULL_TAG;
UF_CURVE_create_line(&LineCoords2, &Line2Tag); //直线1的向量方向,终点减起点
double Vec1[] = {LineCoords1.end_point[]-LineCoords1.start_point[], LineCoords1.end_point[]-LineCoords1.start_point[], LineCoords1.end_point[]-LineCoords1.start_point[]}; //直线2的向量方向,终点减起点
double Vec2[] = {LineCoords2.end_point[]-LineCoords2.start_point[], LineCoords2.end_point[]-LineCoords2.start_point[], LineCoords2.end_point[]-LineCoords2.start_point[]}; //求两个向量的叉乘
double CrossProduct[];
UF_VEC3_cross(Vec1, Vec2, CrossProduct); //已知两个向量求夹角(输出的是弧度)
double Angle;
UF_VEC3_angle_between(Vec1, Vec2, CrossProduct, &Angle); //打印
char msg[];
sprintf(msg, "%f",RADEG*Angle );//角度=180度/π*弧度,或者用宏定义RADEG*弧度
uc1601(msg, ); UF_terminate();

NX二次开发-UFUN已知两个向量方向求夹角角度UF_VEC3_angle_between-LMLPHP

05-11 21:54