如何在POV-Ray中围绕矢量旋转对象?

时间:2017-12-31 02:27:17

标签: rotation geometry povray

我发现很难找到在POV-Ray中将物体从一个给定点移动到另一个点的旋转。

几何上它很容易找到:我计算从原点到目标点>>> def do_something(obj, func): ... obj.func() ... >>> do_something(obj, func) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in do_something AttributeError: 'MyClass' object has no attribute 'func' >>> >>> def do_something(obj, func): ... print obj, func ... >>> do_something(obj, func) <__main__.MyClass object at 0x100686450> <bound method MyClass.doStuff of <__main__.MyClass object at 0x100686450>> >>> >>> >>> def do_something(obj, func): ... func() ... >>> do_something(obj, func) DETAILS: NAME: Rishikesh Agrawani AGE : 25 >>> (绿色)的距离Dist,并在{{1}处创建PointT }} (蓝色)。然后我从Point0<Dist, 0, 0>计算它们之间的角度和它们的垂线。围绕Point0 PointT的{​​{1}}移动AngleD移至Perp = Point0

在POV-Ray中,我可以使用Point1来计算PointT。但我想实际旋转一个物体(当然,它不是一个球体),我也没有看到明显的方法来做到这一点。我尝试了vaxis_rotate,但结果略有不同(红色)。

我如何对一个对象做什么,Point1做了什么?

rotate -AngleD*Perp

enter image description here

3 个答案:

答案 0 :(得分:0)

meowgoesthedog提供的链接中的旋转矩阵给出了预期的结果。

barplot(with(counts3, setNames(x, Group.1)), main = "Booking by Region",
        xlab = "Regions", ylab = "Value")

从上面的例子应用于球体:

#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

答案 1 :(得分:0)

在transforms.inc中查找Axis_Rotate_Trans

#include "transforms.inc" 

sphere {
  ..., ...
  Axis_Rotate_Trans(
    VPerp_To_Plane(<...>, <...>), 
    VAngleD(<...>, <...>)
  )
}

答案 2 :(得分:0)

因此,简而言之,将其设为单位矢量,并假设您想要围绕其旋转alpha度。然后v1 v2 v3 * alpha将不会产生所需的转换。这是一个错误,是一个严重的错误。