码迷,mamicode.com
首页 > 其他好文 > 详细

NXOpen绝对座标值转为WCS座标值

时间:2021-04-20 14:58:16      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:mic   vector   定义   gty   ons   car   gif   err   定义函数   

VS2010 NX8.5

 

//定义函数

Point3d WCSPointTransposeCsysPoint(Point3d origionPoint3D);//工作部件绝对坐标值转化为新坐标下点坐标值
Point3d PointMatrixToNewPoint(Point3d origionPoint3D,Matrix3x3 matrix3X3,Point3d newPoint3D);// 点的转换

 

Point3d HoleTable::WCSPointTransposeCsysPoint(Point3d origionPoint3D) //工作部件绝对坐标值转化为WCS坐标下点坐标值
{
try
{
Point3d WcsOrigin ;//WCS 原点
NXOpen::Matrix3x3 WCSmatrix1;//WCS 矩阵
NXOpen::Vector3d WCSxDirection;//WCS X轴
NXOpen::Vector3d WCSyDirection;//WCS Y轴
NXOpen::CartesianCoordinateSystem* OriginalWcsData = workPart->WCS()->CoordinateSystem();
WcsOrigin = workPart->WCS()->Origin();//获得WCS的原点
WCSmatrix1 = workPart->WCS()->CoordinateSystem()->Orientation()->Element();//获得WCS的矩阵
OriginalWcsData->GetDirections(&WCSxDirection, &WCSyDirection);//获得WCS的XY轴

Point3d tmpPoint3D;//转换
tmpPoint3D.X = origionPoint3D.X - WcsOrigin.X;
tmpPoint3D.Y = origionPoint3D.Y - WcsOrigin.Y;
tmpPoint3D.Z = origionPoint3D.Z - WcsOrigin.Z;

Point3d WCSPoint3D=PointMatrixToNewPoint(tmpPoint3D,WCSmatrix1,origionPoint3D);//点的转换

return Point3d(WCSPoint3D);

}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
HoleTable::theUI->NXMessageBox()->Show("点的转换", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}

Point3d HoleTable::PointMatrixToNewPoint(Point3d origionPoint3D,Matrix3x3 matrix3X3,Point3d newPoint3D)// 点的转换
{
try
{
newPoint3D.X = matrix3X3.Xx * origionPoint3D.X + matrix3X3.Xy * origionPoint3D.Y + matrix3X3.Xz * origionPoint3D.Z;
newPoint3D.Y = matrix3X3.Yx * origionPoint3D.X + matrix3X3.Yy * origionPoint3D.Y + matrix3X3.Yz * origionPoint3D.Z;
newPoint3D.Z = matrix3X3.Zx * origionPoint3D.X + matrix3X3.Zy * origionPoint3D.Y + matrix3X3.Zz * origionPoint3D.Z;
Point3d WCSPoint3D =newPoint3D;//转换后的点
return Point3d(WCSPoint3D);
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
HoleTable::theUI->NXMessageBox()->Show("点的转换", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}

 

 

技术图片

NXOpen绝对座标值转为WCS座标值

标签:mic   vector   定义   gty   ons   car   gif   err   定义函数   

原文地址:https://www.cnblogs.com/hqsalanhuang/p/14673184.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!