POV-Ray : Newsgroups : povray.advanced-users : Get Euler angles from unit vector? Server Time: 12 Dec 2018 21:32:37 GMT
  Get Euler angles from unit vector? (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Mike Horvath
Subject: Get Euler angles from unit vector?
Date: 22 Sep 2018 11:49:25
Message: <5ba62c45$1@news.povray.org>
Is it possible to extract the Euler rotation amounts from a unit vector? 
Is there a command that does this? Thanks.


Mike


Post a reply to this message

From: clipka
Subject: Re: Get Euler angles from unit vector?
Date: 22 Sep 2018 12:32:50
Message: <5ba63672$1@news.povray.org>
Am 22.09.2018 um 13:49 schrieb Mike Horvath:
> Is it possible to extract the Euler rotation amounts from a unit vector?
> Is there a command that does this? Thanks.

A unit vector by itself is not enough to fully specify a free rotation
in 3D space; you need two vectors for that.

Most notably, a single unit vector representation would allow for
arbitrary rotations around the direction of that vector.


Post a reply to this message

From: Le Forgeron
Subject: Re: Get Euler angles from unit vector?
Date: 22 Sep 2018 14:25:46
Message: <5ba650ea$1@news.povray.org>
Le 22/09/2018 à 14:32, clipka a écrit :
> Am 22.09.2018 um 13:49 schrieb Mike Horvath:
>> Is it possible to extract the Euler rotation amounts from a unit vector?
>> Is there a command that does this? Thanks.
> 
> A unit vector by itself is not enough to fully specify a free rotation
> in 3D space; you need two vectors for that.
> 
> Most notably, a single unit vector representation would allow for
> arbitrary rotations around the direction of that vector.
> 
I think he wanted something along Reorient_Trans(Axis1, Axis2) (from
transform.inc) with Axis1 = x and Axis2 his unit vector.

But expressing the transformation as the Euler angles.

Yet, as spotted, a second vector (perpendicular) is needed for complete
non-ambiguous computation.

x,y --> v1,v2


Post a reply to this message

From: Mike Horvath
Subject: Re: Get Euler angles from unit vector?
Date: 22 Sep 2018 15:09:08
Message: <5ba65b14$1@news.povray.org>
On 9/22/2018 8:32 AM, clipka wrote:
> Am 22.09.2018 um 13:49 schrieb Mike Horvath:
>> Is it possible to extract the Euler rotation amounts from a unit vector?
>> Is there a command that does this? Thanks.
> 
> A unit vector by itself is not enough to fully specify a free rotation
> in 3D space; you need two vectors for that.
> 
> Most notably, a single unit vector representation would allow for
> arbitrary rotations around the direction of that vector.
> 


I found some old code written in Lua. Just need to adapt it to POV-Ray.

Mike



-- Returns an array containing the vector's Euler angles, relative to 
the Z-axis.
-- To reproduce the original vector, rotate a point on the Z-axis by 
these angles.
function vanglesXY(tVec2)
	local fSgnX, fSgnY, tPrjB1 = 1, 1, vnormalize({tVec2[1], 0, tVec2[3],})
	if (tPrjB1[1] ~= 0) then
		fSgnX = tPrjB1[1]/abs(tPrjB1[1]) * -1
	end
	tPrjB1[3] = max(min(tPrjB1[3],1),-1)
	local fAngY = acos(tPrjB1[3]) * fSgnX
	local tPrjB2 = vnormalize(vrotate(tVec2, {0, fAngY, 0,}))
	if (tPrjB2[2] ~= 0) then
		fSgnY = tPrjB2[2]/abs(tPrjB2[2])
	end
	tPrjB2[3] = max(min(tPrjB2[3],1),-1)
	local fAngX = acos(tPrjB2[3]) * fSgnY
	return {fAngX * -1, fAngY * -1, 0,}
end


Post a reply to this message

From: Kenneth
Subject: Re: Get Euler angles from unit vector?
Date: 22 Sep 2018 19:40:00
Message: <web.5ba69a61809fadada47873e10@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> Is it possible to extract the Euler rotation amounts from a unit vector?
> Is there a command that does this? Thanks.
>

Methinks you're working on a way to re-structure a transform{matrix...} back
into rotation angles ;-)

[possibly off-topic]
Reading the Wikipedia entry about 'Euler angles' (probably for the first time!),
particularly the 'simplified' form, it reminded me of some test animations I did
years ago, of an object rotating in free space. Like, a chunk of rock slowly
rotating way out in the cosmos.

At first, I thought the object needed THREE separate rotations to look right.
That seemed logical-- if only from the standpoint of an airplane's 'yaw, pitch
and roll.' But the result looked odd-- like there was an extra invisible force
acting on it (and/or that the object was ending up in the same orientation it
started in, very quickly.) Just from experimenting, I found that restricting the
rotations to TWO axes *looked* to be much more natural, and that the third-axis
rotation was... redundant-- which seems to agree with the notion of 'simplified'
Euler angles, where the needed rotations can actually be around two axes rather
than three, to get any orientation (if I'm reading the definition properly, that
is!)

Not that this is of any help to you :-(


Post a reply to this message

From: Mike Horvath
Subject: Re: Get Euler angles from unit vector?
Date: 27 Sep 2018 23:40:38
Message: <5bad6a76$1@news.povray.org>
It would be nice to be able to set vector components like this:

     #local tPrjB1.z = max(min(tPrjB1.z,1),-1);

Are there any plans to do this in the future?



Mike


Post a reply to this message

From: clipka
Subject: Re: Get Euler angles from unit vector?
Date: 27 Sep 2018 23:47:04
Message: <5bad6bf8$1@news.povray.org>
Am 28.09.2018 um 01:40 schrieb Mike Horvath:
> It would be nice to be able to set vector components like this:
> 
>     #local tPrjB1.z = max(min(tPrjB1.z,1),-1);
> 
> Are there any plans to do this in the future?

Thought about it, but it would mean creeping into the dirtiest corners
of the parser.

Not off the agenda, but not right around the corner either.


Post a reply to this message

From: Mike Horvath
Subject: Re: Get Euler angles from unit vector?
Date: 28 Sep 2018 00:32:57
Message: <5bad76b9$1@news.povray.org>
On 9/22/2018 3:39 PM, Kenneth wrote:
> Mike Horvath <mik### [at] gmailcom> wrote:
>> Is it possible to extract the Euler rotation amounts from a unit vector?
>> Is there a command that does this? Thanks.
>>
> 
> Methinks you're working on a way to re-structure a transform{matrix...} back
> into rotation angles ;-)
> 

Yes. Is there a somewhat simple method of doing this so that I don't 
have to write separate code for each possible matrix convention? (There 
are six possibilities, even when not taking into consideration that the 
handedness might also vary.)


Mike


Post a reply to this message

From: Mike Horvath
Subject: Re: Get Euler angles from unit vector?
Date: 28 Sep 2018 01:27:38
Message: <5bad838a$1@news.povray.org>
Two important questions I have (that may not be explained in the docs), 
is how to convert a 3x3 rotation matrix to POV-Ray syntax, and how to 
determine the inverse matrix?


Mike


Post a reply to this message

From: clipka
Subject: Re: Get Euler angles from unit vector?
Date: 28 Sep 2018 04:27:21
Message: <5badada9$1@news.povray.org>
Am 28.09.2018 um 03:27 schrieb Mike Horvath:
> Two important questions I have (that may not be explained in the docs),
> is how to convert a 3x3 rotation matrix to POV-Ray syntax, and how to
> determine the inverse matrix?

given a matrix

     / a  b  c \
    (  d  e  f  )
     \ g  h  i /

you have to specify either

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

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

The order depends on whether the original matrix is specified in
"mathematical" or "computer graphics" style - they're mirrored along the
diagonal. Can't remember which one POV-Ray uses.

Determining the inverse /transformation/ is simple:

    #declare Foo = transform { matrix < ... > }
    #declare FooInv = transform { Foo inverse }

Actually getting at the corresponding matrix is possible by applying the
inverted transformation to the axis vectors.


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

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