在C++中,我们可以绕任意轴旋转点:

void radRotateAxis(float a,float b,float c,float theta)
{
float newX =(
x *(a * a *(1-cosθ)+cosθ)+
y *(a * b *(1-cosθ)-c *sinθ)+
z *(a * c *(1-cosθ)+ b *sinθ));

float newY =(
x *(a * b *(1-cosθ)+ c *sinθ)+
y *(b * b *(1-cosθ)+cosθ)+
z *(b * c *(1-cosθ)-a *sinθ));

float newZ =(
x *(a * c *(1-cosθ)-b *sinθ)+
y *(b * c *(1-cosθ)+ a *sinθ)+
z *(c * c *(1-cosθ)+cosθ));

x = newX;
y = newY;
z = newZ;
}

但是,当我们走theta 0-> 2PI时,这将围绕着围绕您旋转的轴的“单位圆”周围的点

我们如何才能做到θ0-> 2PI,结果大约是宽度为a,高度为b的椭圆?

我不想在围绕轴旋转点之后将变换矩阵应用于这些点-我正在寻找的是“椭圆”旋转矩阵,如果有人知道这样的话!

最佳答案

定义矩阵A以将目标椭圆缩放为合适的单位圆。

然后,A的组成,旋转矩阵和A的逆矩阵就是椭圆旋转矩阵。

09-05 06:57
查看更多