2017-12-31 38 views
0

POV-Ray에서 한 주어진 점에서 다른 점으로 객체를 이동시키는 회전을 찾는 것이 놀랍게 어렵습니다.POV-Ray에서 벡터 주변의 물체를 회전하는 방법은 무엇입니까?

은 기하학적으로는 찾을 수있을만큼 간단합니다 : 내가 목표 지점 PointT (녹색) 원점에서의 거리 Dist을 계산하고 <Dist, 0, 0> (파란색)에 Point0을 만들 수 있습니다. 그런 다음 나는 Point0PointT 사이의 각도와 그것과 수직을 계산합니다. AngleD 주위의 회전은 Point0에서 Point1 = PointT으로 이동합니다. Perp

POV-Ray에서 나는 Point1을 계산하기 위해 vaxis_rotate을 사용할 수 있습니다. 그러나 실제로 객체를 회전시키고 싶습니다. (물론 이것은 구가 아닙니다.)이 작업을 수행하는 확실한 방법은 없습니다. 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} 
} 

enter image description here

+1

http://www.povray.org/documentation/ 보인다 ([오일러 각] 보기/3.6.1/49 /). 필요하다면 [명시적인 회전 행렬] (https://sites.google.com/site/glennmurray/Home/rotation-matrices-and-formulas/rotation-about-an-arbitrary-axis-in-3)을 생성 할 수 있습니다. -치수). – meowgoesthedog

답변

0

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) 
}