利用UF函数来旋转坐标系
实现的功能为程序的坐标点以Z轴为旋转轴 同时 X->Y旋转。
#include <UF_VEC.h> #include <UF_MTX.h> #include <UF_CSYS.h> extern DllExport void ufusr(char *parm, int *returnCode, int rlen) { /* Initialize the API environment */ if (UF_CALL(UF_initialize())) { /* Failed to initialize */ return; } /* TODO: Add your application code here */ char msg[133]; UF_UI_open_listing_window(); const double from_origin[3] = { 0, 0, 0 }; /* <I> origin of csys to map from */ const double from_x_axis[3] = { 0, 1, 0}; /* <I> x axis of csys to map from */ const double from_y_axis[3] = { -1,0, 0 }; /* <I> y axis of csys to map from */ const double to_origin[3] = { 0, 0, 0 }; /* <I> origin of csys to map to */ const double to_x_axis[3] = { 1, 0, 0 }; /* <I> x axis of csys to map to */ const double to_y_axis[3] = {0, 1, 0 }; /* <I> y axis of csys to map to */ double mtx[16]; UF_MTX4_csys_to_csys(from_origin, from_x_axis, from_y_axis, to_origin, to_x_axis, to_y_axis, mtx); const double vec[3] = { 20.150, -1033.000, 0 }; double vec_product[3] = {}; UF_MTX4_vec3_multiply(vec, mtx, vec_product); sprintf_s(msg, "输入坐标为: X%.3fY%.3fZ%.3f", vec[0], vec[1], vec[2]); UF_UI_write_listing_window(msg); UF_UI_write_listing_window("\n"); sprintf_s(msg, "转换坐标为: X%.3fY%.3fZ%.3f", vec_product[0], vec_product[1], vec_product[2] ); UF_UI_write_listing_window(msg); UF_UI_write_listing_window("\n"); /* Terminate the API environment */ UF_CALL(UF_terminate()); }

浙公网安备 33010602011771号