POV-Ray : Newsgroups : povray.general : Convert 313 Cartesian Euler Angles to POV-Ray Coordinates Server Time
23 Nov 2024 20:27:33 EST (-0500)
  Convert 313 Cartesian Euler Angles to POV-Ray Coordinates (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: LAP
Subject: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 9 Sep 2022 10:30:00
Message: <web.631b4c66349a0fb936d75ad24a1f89d@news.povray.org>
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?


Post a reply to this message

From: LAP
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 9 Sep 2022 10:55:00
Message: <web.631b52e07d53bcda36d75ad24a1f89d@news.povray.org>
>
> 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?
>

I neglected to point out that this Euclidean rotation is for an object whose
center of mass is at the origin <0,0,0>.

In POV-Ray it would be the same.  An object is defined with center of mass at
the origin and then rotated.


Post a reply to this message

From: jr
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 9 Sep 2022 13:05:00
Message: <web.631b71987d53bcdaecf5a77b6cde94f1@news.povray.org>
hi,

"LAP" <nomail@nomail> wrote:
> >
> > 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?

my maths is .. non-existent, so cannot answer the question.  however, POV-Ray
applies rotations in axis order, so, if you can convert your matrix to x,y,z
angles, you should be able to use three separate consecutive rotations.

"The order of the rotations does matter. Rotations occur about the x-axis first,
then the y-axis, then the z-axis. If you are not sure if this is what you want
then you should only rotate on one axis at a time using multiple rotation
statements to get a correct rotation."
<https://wiki.povray.org/content/Reference:Transformations#Rotate>


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 9 Sep 2022 14:15:00
Message: <web.631b82857d53bcda1f9dae3025979125@news.povray.org>
"LAP" <nomail@nomail> wrote:

> What is the correct way of transforming this matrix so that it will rotate a
> POV-Ray object in the same way?

Hi,

try looking over the following link, and see if that gives you all that you
need.

http://www.f-lohmueller.de/pov_tut/trans/trans_400e.htm

If not, we can see what additional information you need.

-BW


Post a reply to this message

From: kurtz le pirate
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 10 Sep 2022 02:02:40
Message: <631c2880$1@news.povray.org>
On 09/09/2022 16:24, LAP wrote:

> 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?

not sure, but from memory, POV'matrix is

 | a b c |     < a, b, c,            < a, d, g,
 | d e f | -->   d, e, f,  -- or -->   b, e, h,
 | g h i |       g, h, i,              c, f, i,
                 0, 0, 0 >             0, 0, 0,>



"transforms.inc" can also help you



-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

From: LAP
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 10 Sep 2022 11:20:00
Message: <web.631caa527d53bcda80f7e38f24a1f89d@news.povray.org>
kurtz le pirate <kur### [at] gmailcom> wrote:
>
>  | a b c |     < a, b, c,            < a, d, g,
>  | d e f | -->   d, e, f,  -- or -->   b, e, h,
>  | g h i |       g, h, i,              c, f, i,
>                  0, 0, 0 >             0, 0, 0,>
>

Yes, but the orginal matrix is in Cartesian coordinates [x, y, z].

The POV Ray matrix operates on its own [x,y,z] coordinates which would be
equivalent to the Cartesian [y, z, -x].

Thus, the matrix needs to be changed to:

< d , g, -a,
  e,  h, -b,
  f,  i, -c,
  0,  0,  0 >

So far this seems to work.

Another part of my problem was that I was also using POV Ray scaling and
translate commands which seem to really mess up the rotations.

From now on I will scale and translate with an external script and just use POV
Ray to rotate.  I can also translate with the POV Ray rotation matrix without
distortion because it is a part of the transformation.


Post a reply to this message

From: kurtz le pirate
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 10 Sep 2022 11:37:30
Message: <631caf3a$1@news.povray.org>
On 10/09/2022 17:16, LAP wrote:
> 
> So far this seems to work.
> 
> Another part of my problem was that I was also using POV Ray scaling and
> translate commands which seem to really mess up the rotations.

all tranformations are just **matrix operations**

for scaling :
      | scaleX  0        0      0 |
MSc = | 0       scaleY   0      0 |
      | 0       0       scaleZ  0 |
      | 0       0       0       0 |

scaling point : MSc.pt


for translating :
      | 1 0 0 dx |
MTr = | 0 1 0 dy |
      | 0 0 1 dz |
      | 0 0 0 1  |

translate : MTr.pt
(in povray matrix, the last line)

and, of corse, 'pt' is **also* a matrix

     | x |
pt = | y |
     | z |
     | 1 ]

and the order of application of the transformations is important !



-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

From: kurtz le pirate
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 11 Sep 2022 06:07:54
Message: <631db37a$1@news.povray.org>
On 10/09/2022 17:16, LAP wrote:
> 
> Yes, but the orginal matrix is in Cartesian coordinates [x, y, z].
> 
> The POV Ray matrix operates on its own [x,y,z] coordinates which would be
> equivalent to the Cartesian [y, z, -x].
> 
> Thus, the matrix needs to be changed to:
> 
> < d , g, -a,
>   e,  h, -b,
>   f,  i, -c,
>   0,  0,  0 >
> 
> So far this seems to work.

Hum... yes this is because POVRay use *left-handed system*
Look at this page <http://www.povray.org/documentation/view/3.7.1/15/>

If you want to use *right-handed system* you can change camera settings
See *2.3.1.1.7 Handedness* in
<http://www.povray.org/documentation/view/3.6.1/246/>





-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 17 Sep 2022 10:50:00
Message: <web.6325ddf67d53bcda864c7c4689db30a9@news.povray.org>
"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.

The matrices.inc and vectors.inc files can be found in these libraries:

https://github.com/t-o-k/POV-Ray-matrices

https://github.com/t-o-k/Useful-POV-Ray-macros

I've had a look at how POV-Ray does things internally - and I have tried
to keep the matrices simlar to that, and to do the multiplcations in the
same order. But keep in mind that since POV-Ray uses a left handed
coordinate system, the signs of the rotation angles are opposite of the
rotation angles in a right handed coordinate system.

I based some of the code below on what I found in these articles:

https://en.wikipedia.org/wiki/Euler_angles#Conventions_by_extrinsic_rotations

https://en.wikiversity.org/wiki/PlanetPhysics/Euler_313_Sequence

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


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.7;

#include "../vectors.inc"
#include "POV-Ray-matrices/matrices.inc"
// #include "matrices.inc"

global_settings { assumed_gamma 1.0 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro PrintVector3D(v0)

    #debug concat("<", vstr(3, v0, ", ", 0, -1), ">")

#end // macro PrintVector3D

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#debug "\n\n"

#declare v0 = <+3, -4, +2>;
#debug "v0 = \n"
PrintVector3D(v0)
#debug "\n\n"

#declare MM_0R = M_Row_FromDir3D(v0);
#debug "MM_0R = \n"
M_Print(MM_0R)
#debug "\n\n"

#declare Psi = +30;
#declare Theta = -45;
#declare Phi = +15;

#declare vR =
    vrotate(
        vrotate(
            vrotate(
                v0,
                Psi*z
            ),
            Theta*x
        ),
        Phi*z
    )
;
#debug "vR = \n"
PrintVector3D(vR)
#debug "\n\n"


#declare Transform_313 =
    transform {
        rotate Psi*z
        rotate Theta*x
        rotate Phi*z
    }

#declare vT = VectorTransform(v0, Transform_313);
#debug "vT = \n"
PrintVector3D(vT)
#debug "\n\n"

#declare MM_Rot_313_a = M_FromTransform(Transform_313);
#debug "MM_Rot_313_a = \n"
M_Print(MM_Rot_313_a)
#debug "\n\n"

#declare MM_R_a = M_Mult(MM_0R, MM_Rot_313_a);
#debug "MM_R_a = \n"
M_Print(MM_R_a)
#debug "\n\n"

#declare MM_Rot_Psi = M_Rotate3D_AroundZ(radians(Psi));  // 3
#declare MM_Rot_Theta = M_Rotate3D_AroundX(radians(Theta));  // 1
#declare MM_Rot_Phi = M_Rotate3D_AroundZ(radians(Phi));  // 3
#declare MM_Rot_313_b =
    M_Mult(
        M_Mult(
            MM_Rot_Psi,
            MM_Rot_Theta
        ),
        MM_Rot_Phi
    )
;
#debug "MM_Rot_313_b = \n"
M_Print(MM_Rot_313_b)
#debug "\n\n"

#declare MM_R_b = M_Mult(MM_0R, MM_Rot_313_b);
#debug "MM_R_b = \n"
M_Print(MM_R_b)
#debug "\n\n"

#error "No error, just finished!"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

The result from running the code above:

v0 =
<3.000000, -4.000000, 2.000000>

MM_0R =
array[1][4] {
    {  3.000000, -4.000000,  2.000000,  0.000000 }
}

vR =
<4.434831, 1.214589, 2.803043>

vT =
<4.434831, 1.214589, 2.803043>

MM_Rot_313_a =
array[4][4] {
    {  0.745010,  0.565650, -0.353553,  0.000000 },
    { -0.641457,  0.462097, -0.612372,  0.000000 },
    { -0.183013,  0.683013,  0.707107,  0.000000 },
    {  0.000000,  0.000000,  0.000000,  1.000000 }
}

MM_R_a =
array[1][4] {
    {  4.434831,  1.214589,  2.803043,  0.000000 }
}

MM_Rot_313_b =
array[4][4] {
    {  0.745010,  0.565650, -0.353553,  0.000000 },
    { -0.641457,  0.462097, -0.612372,  0.000000 },
    { -0.183013,  0.683013,  0.707107,  0.000000 },
    {  0.000000,  0.000000,  0.000000,  1.000000 }
}

MM_R_b =
array[1][4] {
    {  4.434831,  1.214589,  2.803043,  0.000000 }
}


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Convert 313 Cartesian Euler Angles to POV-Ray Coordinates
Date: 17 Sep 2022 10:55:00
Message: <web.6325df737d53bcda864c7c4689db30a9@news.povray.org>
"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.
>...

Sorry. The include statements got messed up. They should be:

#include "vectors.inc"
#include "matrices.inc"

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


Post a reply to this message

Goto Latest 10 Messages Next 5 Messages >>>

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