POV-Ray : Newsgroups : povray.general : Convert 313 Cartesian Euler Angles to POV-Ray Coordinates : Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates Server Time
3 Oct 2022 17:18:24 EDT (-0400)
  Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates  
From: Tor Olav Kristensen
Date: 19 Sep 2022 17:15:00
Message: <web.6328da077d53bcda998109289db30a9@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > "LAP" <nomail@nomail> wrote:
> > > I am attempting to use POV-Ray for rigid-body dynamics.
> > >
> > > I have software that produces rotation parameters as 313 Euler angles, psi,
> > > theta, and phi, and the associated 313 rotation matrix.  All this is done in 3D
> > > Euclidean (Cartesian) space.
> > >
> > > The problem I face is converting these Euclidean 313 parameters to work in
> > > POV-Ray coordinates.  In other words, I need to convert the Euclidean rotation
> > > matrix to a POV-Ray matrix so that I can propery rotate objects (and their
> > > textures).
> > >
> > > Since the basic coordinate transform is <x,y,z> Euclidean to <-z, x, y> I have
> > > tried to rearrange the components of the Euclidean 313 rotation matrix to
> > > duplicate this transform but the results are not correct.
> > >
> > > Given a rotation matrix in 3D Euclidean space:
> > >
> > > | 00 01 02 |
> > > | 10 11 12 |
> > > | 20 21 22 |
> > >
> > > What is the correct way of transforming this matrix so that it will rotate a
> > > POV-Ray object in the same way?
> >
> > Hi
> >
> > You may want to have a look at the code below.
> >...
>
> In these expressions:
>
> M_Mult(MM_0R, MM_Rot_313_a) and M_Mult(MM_0R, MM_Rot_313_b)
>
> - in the code in my reply above, row vectors was multiplied by "313" rotation
> matrices.
>
> The code below shows how one can multiply the transposed of the "313" rotation
> matrices with column vectors to achieve the same results (except that the
> vectors are now column vectors instead of row vectors).
>

I should probably mention that the transpose of a rotation matrix is the same
as it's inverse. (It's transpose is also the same as the rotation matrix
formed by changing the sign of all the rotation angles.)

So if you want to use your ready made "313" rotation matrix;

    | m00 m01 m02 |
    | m10 m11 m12 |
    | m20 m21 m22 |

(which I presume is for a right handed coordinate system) in POV-Ray with
POV-Ray's left handed coordinate system and with POV-Ray's "default" camera
vectors, then you can just transpose it and use it in a transform statement
like this:

transform {
    matrix <
        m00, m10, m20,
        m01, m11, m21,
        m02, m12, m22,
          0,   0,   0
    >
}

Since the inverse of a rotation matrix is the same as it's transpose,
this should give the same result:

transform {
    matrix <
        m00, m01, m02,
        m10, m11, m12,
        m20, m21, m22,
          0,   0,   0
    >
    inverse
}


NB:
I have no idea what you mean by this:
"Since the basic coordinate transform is <x,y,z> Euclidean to <-z, x, y> ..."

Also:
You should be careful when you deal with angles in POV-Ray's trigonometric
functions and rotation statements. The trigonometric functions expect the angles
to be in radians, while the rotation statements expect them to be in degrees.
(My POV-Ray matrix library always expect the angles to be in radians.)

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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