NX二次开发-UFUN将矩阵绕任意轴旋转uf5945

函数方法

NX9+VS2012

#include <uf.h>
#include <uf_csys.h>
#include <uf_mtx.h>
#include <uf_trns.h>


UF_initialize();

//初始化3*3矩阵
double x_vec[3] = {1.0, 0.0, 0.0};
double y_vec[3] = {0.0, 1.0, 0.0}; 
double mtx[9];
UF_MTX3_initialize(x_vec, y_vec, mtx);

//创建矩阵
tag_t MatrixTag = NULL_TAG;
UF_CSYS_create_matrix(mtx, &MatrixTag);

//创建坐标系
double csys_origin [3] = {10, 10, 10};
tag_t CsysTag = NULL_TAG;
UF_CSYS_create_csys(csys_origin, MatrixTag, &CsysTag);

for (int i = 0; i < 36; i++)
{
    //将矩阵绕任意轴旋转
    double origin[3] = {10, 10, 10};
    double direction[3]  = {0.0, 0.0, 1.0};
    double degrees_rotation = i;
    double matrix[12];
    int status = 0; 
    uf5945(origin, direction, &degrees_rotation, matrix, &status);

    //变换矩阵
    tag_t objects[] = {CsysTag};
    int n_objects = 1;
    int move_or_copy = 1;
    int dest_layer = 0;
    int trace_curves = 2;
    tag_t copies = NULL_TAG;
    tag_t trace_curve_group = NULL_TAG;
    int status1 = 0;
    uf5947(matrix, objects, &n_objects, &move_or_copy, &dest_layer, &trace_curves, &copies, &trace_curve_group, &status1);
}

UF_terminate();

Caesar卢尚宇
2020年6月21日

数学方法

 关于矩阵数学方面的参考资料https://www.cnblogs.com/zhoug2020/p/7842808.html

NX9+VS2012

#include <uf.h>
#include <uf_csys.h>


UF_initialize();

for (int i = 0; i < 36; i++)
{
    //旋转矩阵(绕Z轴旋转)
    double rot[12]={cos(i),-sin(i),0,sin(i),cos(i),0,0,0,1};

    //创建矩阵
    tag_t MatrixTag = NULL_TAG;
    UF_CSYS_create_matrix(rot, &MatrixTag);

    //创建坐标系
    double csys_origin [3] = {10, 10, 10};
    tag_t CsysTag = NULL_TAG;
    UF_CSYS_create_csys(csys_origin, MatrixTag, &CsysTag);
}

UF_terminate();

Caesar卢尚宇
2020年6月21日

猜你喜欢

转载自www.cnblogs.com/nxopen2018/p/13173905.html
今日推荐