从球坐标旋转体 [英] Rotating body from spherical coordinates
问题描述
是否可以旋转其顶点定义为球坐标的物体.目前,我正在VHDL中进行拼贴项目,并且涉及旋转十二面体并通过VGA进行呈现.
Is it possible to rotate body which has its vertices defined in spherical coordinates. Currently I am doing collage project in VHDL and is about rotating dodecahedron and presenting over VGA.
我应用了针孔相机模型方程,只需要两个sin/cos计算和两个乘法每个顶点.我只是在考虑绕3轴在两个角度上使用3步旋转,但是即使有可能,我也无法找出合适的方程式.
I applied pinhole camera model equations and that required just two sin/cos calculation and two multiplication per vertice. I was just thinking about rotating around 3rd axis using 3 steps over two angles but i am unable to figure out proper equations and even if this is possible.
修改
我想我明白了.
在计算与相机坐标相同的方向的第3轴上旋转仅是相机坐标的2D变换.这意味着,与在3个轴上旋转(2个轴和1个倾斜度)相比,您总共需要进行4次sin/cos计算和4次乘法.如果有人提出更好的建议,请随意发表答案.
Rotating over 3rd axis which is in same direction as camera is just 2D transform of camera coordinates once you you compute them. That mean than for rotating in 3 axes (ok two axis and one inclination) you need to apply total of 4 sin/cos computations and 4 multiplications. If somebody came up whit something better, fell free to post answer.
推荐答案
可以通过更改θ绕y轴旋转,通过更改φ绕z轴旋转.但是,绕x轴旋转会更困难.
You can rotate around the y-axis by changing θ, and rotate around the z-axis by changing φ. Rotating around the x-axis, though, is a bit tougher.
一种简单的方法是将所有内容都转换为直角坐标,执行旋转,然后再转换回去.
One simple way would be to convert everything to catesian coordinates, perform the rotation, and convert back.
(x,y,z)(球面到笛卡尔坐标系)的方程是
The equations for (x,y,z) (spherical-to-cartesian) are
x = r sin θ cos φ
y = r sin θ sin φ
z = r cos θ
绕x轴以角度α旋转(x,y,z)到新点(x',y',z')的方程为
The equations for rotating (x,y,z) to new points (x', y', z') around the x-axis by an angle α are
x' = x
= r sin θ cos φ
y' = y cos α - z sin α
= (r sin θ sin φ) cos α - (r cos θ) sin α
z' = y sin α + z cos α
= (r sin θ sin φ) sin α + (r cos θ) cos α
(r,θ,φ)(笛卡尔对球面)的方程为
The equations for (r, θ, φ) (cartesian-to-spherical) are
r' = sqrt(x'2 + y'2 + z'2)
= r
θ' = cos-1(z'/r')
= cos-1(sin θ sin φ sin α + cos θ cos α)
φ' = tan-1(y'/x')
= tan-1(tan φ cos α - cotan θ sin α sec φ)
我不知道是否有办法进一步降低它,但是应该可以.
I don't know if there is a way to reduce that any further, but it should work.
这篇关于从球坐标旋转体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!