POV-Ray : Newsgroups : povray.advanced-users : finding the rotation vector of the transformation between two reference fra= Server Time
24 Nov 2024 09:25:17 EST (-0500)
  finding the rotation vector of the transformation between two reference fra= (Message 1 to 5 of 5)  
From: chrissounette
Subject: finding the rotation vector of the transformation between two reference fra=
Date: 8 Apr 2007 22:40:01
Message: <web.4619a6979d3b654295b376700@news.povray.org>
Hi Everybody,


http://www.f-lohmueller.de/pov_tut/animate/anim22e.htm), the Spline_Trans()
macro computes the orientation (and position) vector(s) - <Forward, Right,
Up> at each position - that brings the objects along a spline curve. I'm
trying to find the rotation and translation vectors, <Rx,Ry,Rz> and
<Tx,Ty,Tz> respectively, of the transfomation between two flying objects.
Said differently, how can I recover the transformation between two
orthogonal reference frames <Forward_1, Right_1, Up_1> and <Forward_2,
Right_2, Up_2> ????

Cheers,
Chris.


Post a reply to this message

From: Grassblade
Subject: Re: finding the rotation vector of the transformation between two reference= fra=3D
Date: 9 Apr 2007 07:35:00
Message: <web.461a23baf56be1431880c2f80@news.povray.org>
"chrissounette" <nomail@nomail> wrote:
> Hi Everybody,
>

> http://www.f-lohmueller.de/pov_tut/animate/anim22e.htm), the Spline_Trans()
> macro computes the orientation (and position) vector(s) - <Forward, Right,
> Up> at each position - that brings the objects along a spline curve. I'm
> trying to find the rotation and translation vectors, <Rx,Ry,Rz> and
> <Tx,Ty,Tz> respectively, of the transfomation between two flying objects.
> Said differently, how can I recover the transformation between two
> orthogonal reference frames <Forward_1, Right_1, Up_1> and <Forward_2,
> Right_2, Up_2> ????
>
> Cheers,
> Chris.

Hmm, you want to have a conversion between the two? If A1 is the matrix of
the first object, and A2 is the second, you are looking for X such that:
A1*X=A2 sooo X= A1^(-1)*A2. I think.


Post a reply to this message

From: chrissounette
Subject: Re: finding the rotation vector of the transformation between two reference=
Date: 9 Apr 2007 20:05:01
Message: <web.461ad37047487f055ffa356d0@news.povray.org>
"Grassblade" <nomail@nomail> wrote:
> "chrissounette" <nomail@nomail> wrote:
>
> Hmm, you want to have a conversion between the two? If A1 is the matrix of
> the first object, and A2 is the second, you are looking for X such that:
> A1*X=A2 sooo X= A1^(-1)*A2. I think.

Thanks, but it is not so simple. In fact, let consider two orthogonal triads
of unit vectors I = [Forward_1, Right_1, Up_1] and J = [Forward_2, Right_2,
Up_2] with same origin O. Determining the ZYX angles, also known as
Roll-Pitch-Yaw angles, to denote the rotational relationship between the
vectors of these two triads requires to compute first the rotation matrix R
as follow:

[Forward_2 | Right_2 | Up_2] = R * [Forward_1 | Right_1 | Up_1].
-> R = [Forward_2 | Right_2 | Up_2] * [Forward_1 | Right_1 | Up_1]^(-1).

Then the inverse solution to a given rotation matrix R [r11,r12,r13;
r21,r22,r23; r31,r32,r33] can be obtained by:

Roll  = Atan2(r21,r11)
Pitch = Atan2(-r31,sqrt(r32^2+r33^2));
Yaw   = Atan2 (r32,r33);

I'm not expert in Povray yet, and I was wondering if there is a macro
available to do implement this solution ??? If not, I would appreciate if
somobody could help me writing such macro :-)

Thanks,
Chris


Post a reply to this message

From: Tim Attwood
Subject: Re: finding the rotation vector of the transformation between two reference=
Date: 9 Apr 2007 22:21:26
Message: <461af4a6$1@news.povray.org>
I think did something similar in my spline_tools include...
http://news.povray.org/povray.binaries.scene-files/thread/%3C44e2e8f3@news.povray.org%3E/?ttop=240477&toff=50

The spline is passed as a global #declare to avoid certain
bugs that happen when repeatedly passing splines to macros...
VSpline_Trans_Path() in other respects behaves exactly like
Spline_Trans() except it works on a vector in relation to the
origin. You could get the relative up and right vectors for
two positions along your spline by feeding your absolute
up and right into the macro then comparing the returned
vectors.

The only real restriction is that the up vector needs to
be mostly perpendicular to your spline (like Spline_Trans)

// transforms a vector by a matrix
#macro VMatrix_Trans(vec, A, B, C, D)
   #local fn = function { transform {
      matrix < A.x, A.y, A.z,
             B.x, B.y, B.z,
             C.x, C.y, C.z,
             D.x, D.y, D.z>
             } }
   #local result = (fn(vec.x, vec.y, vec.z));
   (result)
#end

// transforms a vector along Path_Spline
#macro VSpline_Trans_Path (Vect, Time, Sky, Foresight, Banking)
   #ifndef (Path_Spline)
      #error "VSpline_Trans_Path requires Path_Spline to be #declared!\n"
   #end
   #local Location = <0,0,0>+Path_Spline(Time);
   #local LocationNext = <0,0,0>+Path_Spline(Time+Foresight);
   #local LocationPrev = <0,0,0>+Path_Spline(Time-Foresight);
   #local Forward = vnormalize(LocationNext-Location);
   #local Right   = VPerp_To_Plane(Sky,Forward);
   #local Up      = VPerp_To_Plane(Forward,Right);
   #local BankingRotation =
   degrees(atan2(
      VRotation(
         VProject_Plane((LocationNext-Location),Sky),
         VProject_Plane((Location-LocationPrev),Sky),
         Up
      )*Banking
      ,1
   ));
   #local result = vrotate(Vect, BankingRotation*z);
   #local result = VMatrix_Trans(result,Right,Up,Forward,Location);
   (result)
#end


Post a reply to this message

From: Grassblade
Subject: Re: finding the rotation vector of the transformation between two reference=
Date: 13 Apr 2007 12:10:01
Message: <web.461faa809a56f91516325b850@news.povray.org>
"chrissounette" <nomail@nomail> wrote:
> Thanks, but it is not so simple. In fact, let consider two orthogonal triads
> of unit vectors I = [Forward_1, Right_1, Up_1] and J = [Forward_2, Right_2,
> Up_2] with same origin O. Determining the ZYX angles, also known as
> Roll-Pitch-Yaw angles, to denote the rotational relationship between the
> vectors of these two triads requires to compute first the rotation matrix R
> as follow:
>
> [Forward_2 | Right_2 | Up_2] = R * [Forward_1 | Right_1 | Up_1].
> -> R = [Forward_2 | Right_2 | Up_2] * [Forward_1 | Right_1 | Up_1]^(-1).
>
> Then the inverse solution to a given rotation matrix R [r11,r12,r13;
> r21,r22,r23; r31,r32,r33] can be obtained by:
>
> Roll  = Atan2(r21,r11)
> Pitch = Atan2(-r31,sqrt(r32^2+r33^2));
> Yaw   = Atan2 (r32,r33);
>
> I'm not expert in Povray yet, and I was wondering if there is a macro
> available to do implement this solution ??? If not, I would appreciate if
> somobody could help me writing such macro :-)
>
> Thanks,
> Chris

Well, I'm not an expert either (yet?), but I think I saw a macro made by
Rune that might do something like what you are looking for. I can't find
the link anymore, though.
POV-ray has commands for dealing with matrices but they are not referenced
in the manual, at least not that I could find.

A straightforward macro using my matrices.inc could go like this, assuming I
and J are the matrices made collating the three vectors:

#macro(I,J)
  #local invI=array[3][3];
  #local R=array[3][3];
  MPGinverse(I,invI) // invI = inverse of I
  matprod(J, invI, R) // R=J*invI
  #declare Roll  = atan2(R[1][0],R[0][0]);
  #declare Pitch = atan2(-R[2][0],sqrt(pow(R[2][1],2)+pow(R[2][2],2)));
  #declare Yaw   = atan2 (R[2][1],R[2][2]);
#end

I'm not sure if atan2 in POV behaves the way you want, I just left it the
way you put it in.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.