当我从欧拉角创建旋转矩阵时,我是否应该将度数(欧拉角)转换为弧度,然后计算 OpenGL 的旋转矩阵? 但是我应该如何处理四元数呢? 我应该执行以下操作吗:
void setQuaternionsFromEuler(float bank, float heading, float attitude)
{
float DegreeToRadian = 3.14f/180.0f;
double c1 = cos(heading/2*DegreeToRadian);
double c2 = cos(attitude/2*DegreeToRadian);
//...
double s3 = sin(bank/2*DegreeToRadian);
this.w = c1*c2*c3 - s1*s2*s3;
//...
}
还有,
void setMatrixFromEuler(float x, float y, float z)
{
float DegreeToRadian = 3.14f/180.0f;
x *= DegreeToRadian;
y *= DegreeToRadian;
//...
}
还是不行?
最佳答案
这取决于您如何定义输入。
C++ 的三角函数专门采用弧度,所以您最终需要转换为弧度,但这可能在数据进入您的程序之前完成(这样资源中的角度值都是弧度)
关于c++ - 弧度还是度数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22068843/