我发现在POV中很难找到物体从一个给定点移动到另一个点的旋转。
几何上,很简单就可以找到:我计算出从原点到目标点的距离Dist (绿色),并在<Dist, 0, 0> (蓝色)创建Point0。然后从Point0和PointT计算出它们之间的夹角和垂直于它们的角度。AngleD围绕Perp的旋转将Point0移动到Point1 = PointT。
在POV中,我可以使用vaxis_rotate计算Point1.但是我想要旋转一个物体(当然,它不会是一个球体),我看不出有什么明显的方法可以做到这一点。我尝试了rotate -AngleD*Perp,但结果略有不同(红色)。
我如何处理一个对象,vaxis_rotate如何处理某个对象?
#declare PointT = <2, 2, 2>;
#declare Dist = VDist(<0, 0, 0>, PointT);
#declare Point0 = <Dist, 0, 0>;
#declare AngleD = VAngleD(PointT, Point0);
#declare Perp = VPerp_To_Plane(PointT, Point0);
#declare Point1 = vaxis_rotate(Point0, Perp, -AngleD);
sphere{Point0, R pigment{color Blue} }
sphere{Point1, R pigment{color Green} }
sphere{
Point0, R
rotate -AngleD*Perp
pigment{color Red}
}

发布于 2017-12-31 11:51:50
meowgoesthedog提供的链接中的旋转矩阵给出了预期的结果。
#macro RotMatFromVectorAndAngle(Vector, Angle)
// takes normalized vector and angle in radians
#local U = Vector.x;
#local V = Vector.y;
#local W = Vector.z;
#local Sin = sin(Angle);
#local Cos = cos(Angle);
#local M11 = U*U + (1-U*U)*Cos;
#local M12 = U*V*(1-Cos) - W*Sin;
#local M13 = U*W*(1-Cos) + V*Sin;
#local M21 = U*V*(1-Cos) + W*Sin;
#local M22 = V*V + (1-V*V)*Cos;
#local M23 = V*W*(1-Cos) - U*Sin;
#local M31 = U*W*(1-Cos) - V*Sin;
#local M32 = V*W*(1-Cos) + U*Sin;
#local M33 = W*W + (1-W*W)*Cos;
matrix <M11, M12, M13,
M21, M22, M23,
M31, M32, M33,
0 , 0 , 0 >
#end应用于上述示例中的球体:
#declare Angle = VAngle(PointT, Point0);
#declare Perp = VPerp_To_Plane(PointT, Point0);
sphere{
Point0, R
RotMatFromVectorAndAngle(Perp, Angle)
}发布于 2018-11-29 21:58:56
查找Axis_Rotate_Trans in transforms.inc
#include "transforms.inc"
sphere {
..., ...
Axis_Rotate_Trans(
VPerp_To_Plane(<...>, <...>),
VAngleD(<...>, <...>)
)
}发布于 2020-05-29 22:45:04
因此,简单地说,假设是一个单位向量,假设你想要一个α度的旋转。然后v1 v2 v3 *alpha将不会产生所需的转换。这是一个错误,一个严重的问题。
https://stackoverflow.com/questions/48039475
复制相似问题