pitch, yaw, roll not working properly

Software: Away3D 4.x

inSertCodE, Sr. Member
Posted: 30 January 2012 07:56 PM   Total Posts: 105

If you rotate an object for example using roll and pitch and rotate them back with the same negative angle you’ll notice that they lack precision which is a huge problem. I’ll be more precise with an example…

if you put this in the render:

Object.roll(5);
Object.pitch(5);
Object.roll(-5);
Object.pitch(-5);

You’ll notice that the object rotates around the Y axis which shouldn’t be the case. It should return in the original position.

You can see what I’m talking about in the attached image. Also here is some data of the traced rotationY:

[20:55:33]  6.96438445795693
[20:55:32]  6.529070035168984
[20:55:32]  6.093760308136091
[20:55:31]  5.658456984405547
[20:55:31]  5.223157929543233
[20:55:30]  4.7878639973227965
[20:55:29]  4.352573480196945
[20:55:29]  3.9172897932602635
[20:55:28]  3.4820122961825177
[20:55:28]  3.0467392814164143
[20:55:27]  2.6114726699526583
[20:55:27]  2.1762120349044256
[20:55:26]  1.7409573762717168
[20:55:25]  1.3057085873328258
[20:55:25]  0.8704662550571348
[20:55:24]  0.43522997923824686

 

   

John Brookes, Moderator
Posted: 30 January 2012 09:38 PM   Total Posts: 732   [ # 1 ]

Shouldnt that be

Object.roll(5);
Object.pitch(5);

Object.pitch(-5);
Object.roll(-5);

   

inSertCodE, Sr. Member
Posted: 30 January 2012 10:33 PM   Total Posts: 105   [ # 2 ]

Hmmm… That actually works. Its still a bug because the axis is the same no mater what the order of the command is unlike rotation, but its good enough for me.

   

John Brookes, Moderator
Posted: 31 January 2012 09:31 AM   Total Posts: 732   [ # 3 ]

Not a bug, its how it works.
Your rotating about the objects own axis.

   

inSertCodE, Sr. Member
Posted: 31 January 2012 11:08 PM   Total Posts: 105   [ # 4 ]
JohnBrookes - 31 January 2012 09:31 AM

Not a bug, its how it works.
Your rotating about the objects own axis.

I don’t think you understand… That’s exactly how it should work, rotate around its own axis. So no mater of previous rotation personal axis remains the same. So unlike regular rotation the order of using roll, pitch and yaw shouldn’t mater.

In other words:

Object.roll(5);
Object.pitch(5);
Object.roll(-5);
Object.pitch(-5);

...should give the exact same result (the object returning in original position) as:

Object.roll(5);
Object.pitch(5);
Object.pitch(-5);
Object.roll(-5);

Instead it slightly rotates the object around the Y axis as if you were using “yaw”. I hope you see my point now.

   

John Brookes, Moderator
Posted: 01 February 2012 12:54 AM   Total Posts: 732   [ # 5 ]

This does
Object.roll(90);
Object.pitch(90);
Object.roll(-90);
Object.pitch(-90);

http://www.shrewballooba.co.uk/rot/
double click for it to tween through

Its doing exactly as asked.
As soon as you rotate someting its local axis changes from the global.

   

inSertCodE, Sr. Member
Posted: 01 February 2012 02:43 PM   Total Posts: 105   [ # 6 ]

Dear god… Did you read at least one of my posts? Instead of popping up answers take 1 minute and do the test yourself or at least take a look at the screenshot.

Put an object on the scene and put this in the render frame

Object.roll(5);
Object.pitch(5);
Object.roll(-5);
Object.pitch(-5);

Nothing should move. But instead the object rotates slightly around Y axis. I simply can’t figure out a way to explain it more simple than that.

PS. i think the problem is with the limited decimal spaces a number can take in pitch,roll and yaw calculation. I’m not sure anything can be done about that but maybe some of you can.
Here is an example that is not connected to pitch, roll and yaw functions but can explain what could happen.
tangent from 1.11111111 is 48.01278747 If the initial number had more decimals but was rounded on 8 because of the limit it will get different no. egs. tangent from 1.11111112 is 48.01278773
That is 0.00000026 degrees difference. If you run that at 60fps you will get 0.0000156 miss-rotated degrees per second and after some time it starts to be notable.

   

John Brookes, Moderator
Posted: 01 February 2012 03:31 PM   Total Posts: 732   [ # 7 ]

Sweet jebus have you read a thing I’ve said?
How about put
Object.roll(90);
Object.pitch(90);
Object.roll(-90);
Object.pitch(-90);

in the render frame and watch it go mad.

Then look at that demo I posted and think to yourself thats what happens every frame.
And notice IT DOESNT RETURN TO THE ORIGINAL POSITION.

Back in your render loop
It doesnt mash all the rotations together and stick them in the transform in one go.

It steps through
roll set transform
pitch set transform
roll set transform
pitch set transform
render.

ps calm down dear wink

   

inSertCodE, Sr. Member
Posted: 01 February 2012 06:03 PM   Total Posts: 105   [ # 8 ]

Ok i see the point now. So with every rolling, pitching or yawing the axis rotates with the model too right? Sorry for being rude, I thought of “own axis” differently so I was convinced that

Object.roll(5);
Object.pitch(5);
Object.roll(-5);
Object.pitch(-5);

should return it in original position and I was mad you couldn’t see that :D

   

John Brookes, Moderator
Posted: 01 February 2012 09:14 PM   Total Posts: 732   [ # 9 ]

“So with every rolling, pitching or yawing the axis rotates with the model too right?”
Yes.

yaw roll pitch you would use for things like controlling a plane.
Basically when you want to rotate something about its own axis.
So if the plane is flying in any direction, roll will always ‘roll’ the plane around its direction of travel.
Same as pitch will push the nose of the plane up/down around the axis of the wings.

Or another way
yaw rotates about the objects upVector (the green axis on a trident added to that object)
pitch rotates about the objects right vector (the red axis)
roll rotates about the objects forward vector (the blue axis)

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X