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.

Code Snippets / Global and Local Rotation Functions (DBP)

Author
Message
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 1st Jan 2007 07:07 Edited at: 4th Jan 2007 01:38
I have just finished writing some rotation functions. I was going to use quaternions but couldn't figure them out for the life of me, so I wrote them in a way that made sense to me. You can also rotate object about any desired axis. Current list of functions:



Edit:Fixed a bug in some functions that caused the object the freak out when it was not positioned at (0,0,0), and added an Orbit() function, which takes an object, a position, and a direction, and the object will rotate around the axis defined by the point and direction.

Edit:Improved the functions so that they no longer use the cross product and dot product for normal global and location rotations, meaning that the bug where the object slowly turn due to floating point inaccuracies no longer exists. Also added functions that return the standard AxisAngleY,AxisAngleX, and AxisAngleZ, and the up direction can be specified on those as well.
NewGuy
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: Interdimensional vortex
Posted: 1st Jan 2007 19:24
I will definatly find a use for this next time I do something 3d!! I rember trying to make rolling balls (no luck)


Very nice, good job, congratz!

And on the pedestal these words appear:
"My name is Ozymandias, king of kings: Look on my works, ye mighty, and despair!"
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 1st Jan 2007 23:44
Same here new guy. This should really be helpfull, especially for my physics library. Cheers LL

lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 2nd Jan 2007 00:28 Edited at: 2nd Jan 2007 01:28
Thanks
I'm also making some functions that will allow you to do more. I just finished a function that will align an arbitrary local axis to align with an arbitrary global axis. For example, Align_Axes(obj,0,1,0,0,1,0) will rotate the object such that it is standing up.
Edit:
First post updated with new functions. Also the bug where the object disappears is gone.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 2nd Jan 2007 01:28
I'm not quite sure how that works - but I'll take your word

I was wanting to ask a question. This would be very usefull for my physics library, because:

If the ball is moving forwards, and facing forwards, it's all fine just rotating it round the x axis. But, if I still move in the same direction, but slowly turn to face another direction, I need to to still rotate the same way. Then ofcourse there's trouble when I start moving in another direction.

The question is, would I rotate it always in the global axis? Or would there be some bits that would rotate round the local axis? Or am I wrong all together?

lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 2nd Jan 2007 01:31 Edited at: 4th Jan 2007 01:34
Quote: "

If the ball is moving forwards, and facing forwards, it's all fine just rotating it round the x axis. But, if I still move in the same direction, but slowly turn to face another direction, I need to to still rotate the same way. Then ofcourse there's trouble when I start moving in another direction.

The question is, would I rotate it always in the global axis? Or would there be some bits that would rotate round the local axis? Or am I wrong all together?
"

I'd find the direction the ball is rolling in (using atanfull on the x and z velocities or something similar), turn that vector by 90 degrees around the global y axis, and then rotate the ball around that vector using the axis rotation method.
Edit: Here's an example of a ball rotating in the direction it is going, something I bet lots of DBP users have wanted to do for a long time but couldn't because of DBP's euler rotation system.
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 15th Jan 2007 23:23
THIS IS FREAKING AWESOME!!!!!!!! Thanks! You've saved me months of confusion!!

"There will always be evil, for, without evil, the good shall lose their virtue."
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 16th Jan 2007 12:28
For the current version of the code, which includes several new functions, go to the WIP post at http://forum.thegamecreators.com/?m=forum_view&t=96978&b=8&p=0#m1089609.

Login to post a reply

Server time is: 2024-11-23 00:11:29
Your offset time is: 2024-11-23 00:11:29