opencascade获取四元数、旋转矩阵和欧拉角
如图,计算结果与PowerMill中的结果进行对照
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210525230550945.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2hhMGhhMHh1ZXhp,size_16,color_FFFFFF,t_70)
在opencascade中当我们想要获取两个坐标轴之间的旋转关系时,如旋转矩阵、旋转四元数以及欧拉角等可以按照如下步骤进行:
void angleTest(gp_Ax3 FromSystem, gp_Ax3 ToSystem)//变换前后的坐标系
{
gp_Trsf trsf;
trsf.SetTransformation(FromSystem, ToSystem);
gp_Quaternion quaternion = trsf.GetRotation();//获取四元数,存储了旋转信息
gp_Mat mat=quaternion.GetMatrix () ;//获取旋转矩阵
Standard_Real theAlpha, theBeta, theGamma;
//从四元数中获取欧拉角,一共有24种,根据需要添加
quaternion.GetEulerAngles(gp_Intrinsic_XYZ, theAlpha, theBeta, theGamma);
//与PowerMill中每个数值差一个负号,输出角度
cout <<"角度:"<< -theAlpha * 180 / PI << "," << -theBeta * 180 / PI << "," << -theGamma * 180 / PI << endl;
}
其余更多的旋转信息都可以在gp_Trsf、gp_Quaternion中获取。