Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / example of SetObjectRotationQuat

Author
Message
basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 17th May 2013 01:12 Edited at: 17th May 2013 01:23
am trying to make rotation using euler (no problem at all) and quaternion (problem)

did anyone work on it? please correct my example:

(am ok in term of understanding the quaternion mathematic but it seems am not managing to apply it in here.)



basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 17th May 2013 01:22 Edited at: 17th May 2013 01:24
--
sorry the message seemed to be posted twice so I deleted this one.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 17th May 2013 13:38 Edited at: 17th May 2013 13:40
SetObjectRotation is ok for a start angle at all axis but there is a axis order. one axis can affect a other.

its better you rotate relativ and not absolute.
RotateObjectLocalX
RotateObjectLocalY
RotateObjectLocalZ
RotateObjectGlobalX
RotateObjectGlobalY
RotateObjectGlobalZ

Quaternion i can't explain
http://en.wikipedia.org/wiki/Quaternion

a little bit you can read in help file, F1 over command SetObjectRotationQuat
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th May 2013 14:21
One good example might be a rolling ball, like a pool ball for example. You might use the local rotation to set it as random, like a random orientation - but then use the global rotation on X and Z depending on the objects movement, to replicate the ball rolling around a table. I've actually made a pool table simulation using 3D pool balls controlled via sprites with Box2D, works remarkably well - just a shame that Box2D doesn't really cut it for a pool game (at least as far as I can tell).

The local rotations affect the object locally, so if you rotate an object locally on 2 or more axis, it can be difficult to predict the results, especially if Z rotation comes into play. Local rotation is good when you only need to rotate one axis, like turning a turret, you'd rotate on the Y axis - but if you needed to rotate the turret up and down, rotating on the X axis globally would work - but rotating on the X axis locally would probably not.

I got a fever, and the only prescription, is more memes.
basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 17th May 2013 14:30
thanks guys, I don't have a problem with local and global rotation.

the Quaternion system is better in solving real life cases where we need to make a smooth rotation from one point to another. however, it seems that am unable to apply it here.

Brendy boy
18
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 18th May 2013 02:42 Edited at: 18th May 2013 02:43
x#,y#,z# are directions of a rotation axis and w# is amount of rotation around that axis

For example:
-you want to rotate an object around y axis for 33 degrees:
x#=0, y#=1, z#=0, w#=33

basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 19th May 2013 15:28
still not working:



Brendy boy
18
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 19th May 2013 21:40
are you sure that parameters are in that order - w#,x#,y#,z#?
I don't have AppGameKit so i can't check but maybe they're in different order - have you tried x#,y#,z#,w#?

basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 19th May 2013 22:26
yep the parameters are w#,x#,y#,z#. I already tried x#,y#,z#,w# as I thought there could be something wrong but didn't work.

lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 19th May 2013 22:30
Quote: "y#=y#+3"


Aren't the quaternions supposed to be between 0.0-1.0?

My hovercraft is full of eels
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 19th May 2013 22:49 Edited at: 19th May 2013 23:05
Indeed, I can't see anywhere that says the values are angles.
(but then I can't see anywhere that says they are not)

For the command GetObjectQuatY, it states "Returns the Y component of the object's current rotation converted to a quaternion."

The use of the word "converted", suggests it's a bit more complex.

You can add the following to show the current angle

Sadly, none of this helped me find an answer and the wiki page just gave me a headache

So I think we need a maths expert or the guy who included this in AppGameKit

EDIT:

Limiting to 0.0 to 1.0 with the following;

Does give Y rotation - kind of - but it's not the full picture yet
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 19th May 2013 23:04 Edited at: 19th May 2013 23:07
this turn around a axis.

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 19th May 2013 23:28
Markus, you are the man

I got more out of 10 short lines of code than the pages upon pages of math gibberish and doublespeak in the Wiki.

Makes sense that it would be sines and cosines if the range is 0 to 1, though it wouldn't have hurt to mention that in the docs.

Login to post a reply

Server time is: 2024-05-07 01:47:01
Your offset time is: 2024-05-07 01:47:01