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.

Newcomers DBPro Corner / How to rotate an object around a point?

Author
Message
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 27th Feb 2005 19:53
How do you rotate an object around a point?

E.G A Planet orbiting the sun.
Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 27th Feb 2005 19:56
you'll need sin, cos and an angle

distance# = 50.0
x# = 0.0 + sin(angle) * distance#
z# = 0.0 + cos(angle) * distance#

now when you position something on X# and Z#, it will rotate around point
X0.0, Z0.0

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 27th Feb 2005 20:01
Could you explain that a bit more please?

I have this code but it doesnt work

Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 27th Feb 2005 20:15
well, sin and cos return values when you give them an angle... in your case you give them 0.1, this means the object will always stay at angle 0.1

In order to rotate, you need an increasing value:

do
angle# = wrapvalue(angle# + 1.0)
distance# = 50.0
x# = 0.0 + sin(angle#) * distance#
z# = 0.0 + cos(angle#) * distance#
position object 30,x#,object position y(16),z#
loop

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 27th Feb 2005 20:24
Oh i see

Sorry i phrased my question wrongly,

I meant that i would like the end of the object to rotate around a point like a snooker queue rotating around a ball when left or right is pushed
Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 27th Feb 2005 20:36
well, its the same so you could use the code from above

add a point object command that points your queue towards the ball.
Now only add or decrease the angle when you hit left or right

Dark Flame
19
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 27th Feb 2005 20:46
It would be easier if you just gave him the code and annotated it for him.
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 27th Feb 2005 21:04
Yes it would

I haven't done sin or cos in maths yet so i am a bit confused
Dark Flame
19
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 28th Feb 2005 04:20
Neither have i...even tho i left school 2 years ago and now doing computer science at college. So i may have the same problem as you when i need to deal with sin or cos.
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 1st Mar 2005 07:55 Edited at: 1st Mar 2005 07:56
This is just a little routine to help, it only calculated rotation round a point in the y axies though ( as in like the pic below ).

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-09-23 13:25:02
Your offset time is: 2024-09-23 13:25:02