zoukankan      html  css  js  c++  java
  • NX二次开发-UFUN计算两点距离UF_VEC3_distance

     1     NX11+VS2013
     2     
     3     #include <uf.h>
     4     #include <uf_curve.h>
     5     #include <uf_vec.h>
     6     
     7     UF_initialize();
     8 
     9     //创建点1
    10     double Point1[3] = { 10.0, 10.0, 10.0 };
    11     tag_t  PointTag1 = NULL_TAG;
    12     UF_CURVE_create_point(Point1, &PointTag1);
    13 
    14     //创建点2
    15     double Point2[3] = { 100.0, 100.0, 100.0 };
    16     tag_t  PointTag2 = NULL_TAG;
    17     UF_CURVE_create_point(Point2, &PointTag2);
    18     
    19     //求两点距离
    20 
    21     //方法1(数学方法)
    22     double Distance = sqrt(pow(Point2[0] - Point1[0], 2) + pow(Point2[1] - Point1[1], 2) + pow(Point2[2] - Point1[2], 2));
    23 
    24     //方法2(函数UF_VEC3_distance)
    25     double  Distance1;
    26     UF_VEC3_distance(Point1, Point2, &Distance1);
    27 
    28     //打印
    29     char msg[256];
    30     sprintf_s(msg, "两点之间距离为:%f", Distance);
    31     lw->Open();
    32     lw->WriteLine(msg);
    33 
    34     UF_terminate();
    35 
    36     Caesar
    37     注:(方法1是看唐工百度传课NX二次开发课程学会的)

  • 相关阅读:
    判断js中的类型
    js数组的4种遍历方式
    js笔记
    Windows 常用 CMD 命令介绍
    css笔记
    winform项目笔记:
    Angular4 中内置指令的基本用法
    Angular4入门笔记
    8、跳台阶
    7、斐波那契数列
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/10957249.html
Copyright © 2011-2022 走看看