zoukankan      html  css  js  c++  java
  • NX二次开发-从一个坐标系到另一个坐标系的转换

    函数:UF_MTX4_csys_to_csys()、UF_MTX4_vec3_multiply()

    函数说明:从一个坐标系统到另一个坐标系统的转换。如下图红色坐标系下有个红色的点,将红色的点转到绿色的坐标系下,得到绿色的点。可以使用UF_MTX4_csys_to_csys()和UF_MTX4_vec3_multiply()函数。

    三个角度的截图:

     1 // UF_MTX4_csys_to_csys从一个坐标系统到另一个坐标系统的转换:*
     2 
     3 #include <stdio.h>
     4 #include <uf.h>
     5 #include <uf_part.h>
     6 #include <uf_defs.h>
     7 #include <uf_modl.h>
     8 #include <uf_mtx.h>
     9 
    10 #define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
    11 
    12 static int report(char *file, int line, char *call, int irc)
    13 {
    14     if (irc)
    15     {
    16         char    messg[133];
    17         printf("%s, line %d:  %s
    ", file, line, call);
    18         (UF_get_fail_message(irc, messg)) ?
    19             printf("    returned a %d
    ", irc) :
    20             printf("    returned error %d:  %s
    ", irc, messg);
    21     }
    22     return(irc);
    23 }
    24 
    25 static void do_ugopen_api(void)
    26 {
    27 
    28 
    29     double  from_origin[3] = { 0.0, 0.0, 0.0 };
    30     double  from_x_axis[3] = { 1.0, 0.0, 0.0 };
    31     double  from_y_axis[3] = { 0.0, 1.0, 0.0 };
    32 
    33     double  to_origin[3] = { 10.0, 10.0, 10.0 };
    34     double  to_x_axis[3] = { 0.0, 1.0, 0.0 };
    35     double  to_y_axis[3] = { 1.0, 0.0, 0.0 };
    36 
    37     double  new_target[3];
    38     double  target[3] = { 2, 4, 6 };
    39 
    40     tag_t tagP_target;
    41     UF_CURVE_create_point(target, &tagP_target);//创建点
    42 
    43     double  transform[16];
    44     tag_t   part_tag;
    45     UF_CALL(UF_MTX4_csys_to_csys(from_origin, from_x_axis, from_y_axis,to_origin, to_x_axis, to_y_axis,transform));
    46     UF_MTX4_vec3_multiply(target, transform, new_target);
    47     
    48     tag_t tagP_new_target;
    49     UF_CURVE_create_point(new_target, &tagP_new_target);//创建转换后的点
    50 
    51 }
    52 
    53 
    54 void ufusr(char *param, int *retcode, int param_len)
    55 {
    56     if (!UF_CALL(UF_initialize()))
    57     {
    58         do_ugopen_api();
    59         UF_CALL(UF_terminate());
    60     }
    61 }
    62 
    63 int ufusr_ask_unload(void)
    64 {
    65     return (UF_UNLOAD_IMMEDIATELY);
    66 }
  • 相关阅读:
    Milking Time---poj3616(简单dp)
    elasticsearch-入门(一)
    Spring Cloud Sleuth(十四)
    Spring Cloud Stream(十三)
    Spring Cloud-Bus(十二)
    Spring Cloud-config(十一)
    mac Gitblit安装
    git学习笔记
    java陷阱之spring事物管理导致锁无效
    Spring Cloud-Zuul(十)
  • 原文地址:https://www.cnblogs.com/KMould/p/12553308.html
Copyright © 2011-2022 走看看