怡宁塑胶模具设计

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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());
}
}

 

 

posted on 2021-04-18 12:28  怡宁塑胶模具设计  阅读(447)  评论(0编辑  收藏  举报