[PD] GEM/math: correctly rotating in space

Tebjan Halm tebjan at gmx.de
Sun Oct 16 22:27:52 CEST 2005


hi,

was tricky, but there is a more or less easy solution if you use two rotate
objects. first rotate around the z axis with:

180/3.14159265 * atan2($f2, $f1);

then rotate the cube around its y axis with:

180/3.14159265 * (acos($f3/$f4)-3.14159265/2);

where $f4 is the length of the diff vector. the subtraction of half pi 
(90 degree)
was found by trial and error ...

attached is the solution (i hope).

have fun !

tebjan

Frank Barknecht schrieb:

>Hallo,
>Tebjan Halm hat gesagt: // Tebjan Halm wrote:
>
>  
>
>>if i understand your patch, you just have to calculate the
>>angles of the spherical coordinates of your second point.
>>
>>r = length (of your diff vector)
>>
>>angle 1:
>>atan2( y, z )
>>
>>angle 2:
>>acos( z/r )
>>
>>angle3:
>>0
>>
>>and remember, two angles are always sufficiant in 3d space ;)
>>    
>>
>
>This sounds good and thank you a lot for this clarification.  Now with
>my first rotation around the Z-axis I basically do the transformation
>to polar coordinates: distance r and angle inside the XY-plane. IIR I
>then need to rotate again by the angle, that the difference vector has
>to the xy-plane (often called Phi and basically it is "angle 2")
>
>However while I think I know how to find the correct angle, I still
>have difficulties to find the *axis* to rotate around.  In (my) theory
>I would need to rotate around the vector, which is the result of the
>outer/cross product of the difference vector and the z-axis, because
>that is the vector which is rectangular to both the diff. vector and
>z-axis. However I already tried that, and it still looks very wrong. 
>
>Ciao
>  
>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: move-in-space.pd
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20051016/0d8a9377/attachment.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: solid-link.pd
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20051016/0d8a9377/attachment.txt>


More information about the Pd-list mailing list