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.

DarkBASIC Professional Discussion / Hinge rotation angle math problem in Newton

Author
Message
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 22nd Mar 2011 23:18 Edited at: 22nd Mar 2011 23:20
So it took me some time to figure out how hinges are rotated in Newton. They must be rotated with vector, but I'm having math issues how I convert angles to that format.

Easy angles are 0,90,180 and 270 they are indicated like this(respectively):
NDB_SetVector 2, 1.0, 0.0, 0.0
NDB_SetVector 2, 0.0, 0.0, -1.0
NDB_SetVector 2, -1.0, 0.0, 0.0
NDB_SetVector 2, 0.0, 0.0, 1.0

Then it gets a bit more difficult, middle angles 45,135,225 and 315 respectively:
NDB_SetVector 2, 0.5, 0.0, -0.5
NDB_SetVector 2, -0.5, 0.0, -0.5
NDB_SetVector 2, -0.5, 0.0, 0.5
NDB_SetVector 2, 0.5, 0.0, 0.5

But how do I make a convertion of angles like 113 degrees, or 277 degrees, so that I don't have to figure them out separeately?
I tried to come up with converter, but I can't figure anything out for angles 270<rx#<360... And that converts only the other half of the values.


Here is image that will confuse you even more>


I don't know am I tired, but I can't come up with wise solution for this.
Jimmy
22
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 22nd Mar 2011 23:57
Cosine and Sine are your friends for this one, friend!

And you're right, that image confuses the beans out of me, but what I recommend trying is a little of this:

NDB_SetVector 2, Cos(45), 0.0, Sin(45)
NDB_SetVector 2, Cos(135), 0.0, Sin(135)
NDB_SetVector 2, Cos(90), 0.0, Sin(90)
NDB_SetVector 2, Cos(113), 0.0, Sin(113)

You can also swap the Cos and Sin functions if you're not quite getting the results you need, like so:

NDB_SetVector 2, Sin(113), 0.0, Cos(113)

Hope that helps!

NaGaFailMo.
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 23rd Mar 2011 15:58 Edited at: 23rd Mar 2011 15:59
Oh, I totally didn't think of trigonometric functions for this one, but now that I think of it, it makes sense.

I ended up using this which works universally throughout 0-360 degrees:
NDB_SetVector 2, cos(-ry#), 0.0, sin(-ry#)
For some reason I have to use negative angle values so that it will work.

Thanks Jimmy!

Login to post a reply

Server time is: 2026-07-17 02:54:02
Your offset time is: 2026-07-17 02:54:02