zoukankan      html  css  js  c++  java
  • 【NX二次开发】uf5945获得旋转矩阵、uf5947根据变换矩阵移动或复制对象

    返回一个矩阵,可以绕任意轴旋转。

    与uf5947结合可以将对象沿着任意轴进行旋转。不是所有对象都能用uf5947变换,带参的实体、部件都不可以用此函数变换。下面是旋转WCS的例子。

    extern DllExport void ufsta(char *param, int *returnCode, int rlen)
    {
        UF_initialize();
        tag_t wcs_id;
        UF_CSYS_ask_wcs(&wcs_id);
    
        tag_t matrix_id = NULL_TAG;
        double o_point[3];//旋转轴通过的点
        double vec[3];//旋转轴方向
        UF_CSYS_ask_csys_info(wcs_id, &matrix_id, o_point);
        //获得 3x3矩阵数据
        double wsc_9[9];
        UF_CSYS_ask_matrix_values(matrix_id, wsc_9);
        
        //UF_MTX3_x_vec(wsc_9, vec);//绕X轴逆时针旋转
        //UF_MTX3_y_vec(wsc_9, vec);//绕X轴逆时针旋转
        UF_MTX3_z_vec(wsc_9, vec);//绕Z轴逆时针旋转
    
        double angle = 90.0;
        double matrix16[16]; //矩阵
        int status;
        uf5945(o_point, vec, &angle, matrix16, &status);
    
        int objects = 1;        //数量
        int  move = 2;            // 1 :移动 2 :复制
        int  layer = -1;        //0:最初层; -1: 工作层; 1 - 256 : 指定层
        int trace_curves = 2;    //轨迹状态, 1 开, 2 关
        tag_t wsc_t2 = NULL_TAG; //变化后坐标tag
        //uf5947将某个obj进行移动或复制
        uf5947(matrix16, &wcs_id, &objects, &move, &layer, &trace_curves, &wsc_t2, NULL, &status);//第二个对象 为被移动的对象
    
        UF_CSYS_set_wcs(wsc_t2);
        UF_terminate();
    }
    
    extern int ufusr_ask_unload(void)
    {
        return (UF_UNLOAD_IMMEDIATELY);
    }

    效果:

     将一个四方块,旋转复制变成3个试试:

    源码:

    extern DllExport void ufsta(char *param, int *returnCode, int rlen)
    {
        UF_initialize();
        double o_point[3];//旋转轴通过的点
        double vec[3];//旋转轴方向
        tag_t tagBody1 = 45655;
        tag_t tagBody2 = NULL_TAG;//复制的第一个体
        tag_t tagBody3 = NULL_TAG;//复制的第二个体
            
        tag_t wcs_id;
        UF_CSYS_ask_wcs(&wcs_id);
        tag_t matrix_id = NULL_TAG;
        UF_CSYS_ask_csys_info(wcs_id, &matrix_id, o_point);
        //获得 3x3矩阵数据
        double wsc_9[9];
        UF_CSYS_ask_matrix_values(matrix_id, wsc_9);
        
        //UF_MTX3_x_vec(wsc_9, vec);//绕X轴逆时针旋转
        //UF_MTX3_y_vec(wsc_9, vec);//绕X轴逆时针旋转
        UF_MTX3_z_vec(wsc_9, vec);//绕Z轴逆时针旋转
    
        double angle = 120;
        double matrix16[16]; //矩阵
        int status;
        uf5945(o_point, vec, &angle, matrix16, &status);
    
        int objects = 1;        //数量
        int  move = 2;            // 1 :移动 2 :复制
        int  layer = -1;        //0:最初层; -1: 工作层; 1 - 256 : 指定层
        int trace_curves = 2;    //轨迹状态, 1 开, 2 关
    
        //uf5947将某个obj进行移动或复制
        uf5947(matrix16, &tagBody1, &objects, &move, &layer, &trace_curves, &tagBody2, NULL, &status);
        uf5947(matrix16, &tagBody2, &objects, &move, &layer, &trace_curves, &tagBody3, NULL, &status);
    
        UF_terminate();
    }
    
    extern int ufusr_ask_unload(void)
    {
        return (UF_UNLOAD_IMMEDIATELY);
    }

    效果:

  • 相关阅读:
    hdu 5170 GTY's math problem(水,,数学,,)
    hdu 5178 pairs(BC第一题,,方法不止一种,,我用lower_bound那种。。。)
    hdu 5179 beautiful number(构造,,,,)
    cf12E Start of the season(构造,,,)
    cf12D Ball(MAP,排序,贪心思想)
    cf 12C Fruits(贪心【简单数学】)
    cf 12B Correct Solution?(贪心)
    hdu 5171 GTY's birthday gift(数学,矩阵快速幂)
    hdu 5172 GTY's gay friends(线段树最值)
    cf 11D A Simple Task(状压DP)
  • 原文地址:https://www.cnblogs.com/KMould/p/13969710.html
Copyright © 2011-2022 走看看