





 
 




 
 


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


 
 




 
 


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


 
 




 
 


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
nonambiguous computation.
x,y > v1,v2
Post a reply to this message


 
 




 
 


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 POVRay.
Mike
 Returns an array containing the vector's Euler angles, relative to
the Zaxis.
 To reproduce the original vector, rotate a point on the Zaxis 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


 
 




 
 


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 restructure a transform{matrix...} back
into rotation angles ;)
[possibly offtopic]
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 thirdaxis
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


 
 




 
 


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


 
 




 
 


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


 
 




 
 


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


 
 




 
 


Two important questions I have (that may not be explained in the docs),
is how to convert a 3x3 rotation matrix to POVRay syntax, and how to
determine the inverse matrix?
Mike
Post a reply to this message


 
 




 
 


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


 
 




 

