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 / Math: Function to convert radians to degrees within DB?

Author
Message
GregA
13
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 29th Jun 2011 02:21
So awating delivery of Enhanced animation... And this is an oportunity to roll my own in DB

In the meantime, I opened up an .x file extraced my animation bits that I need. and came up with this...



which I converted to...



A little googling around and I discover these values represent w, x, y and z and they appear to be in radians rather than degrees.

So... Looking around the DBPro docs I have two issues...

First does DBPro have a function to convert radians to degrees?

Second, can I populate a matrix with a w component???
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Jun 2011 02:29
It's very simple to convert radians.

degrees = radians * 180 / Pi

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Jun 2011 12:38
Yeah, I tend to just divide my angles by 57.295779513, or multiply radians by the same amount.

Not that I use that in DBPro usually, it's something I find myself doing in C++, DBPro is pretty consistant with angles and stuff.

Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
18
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jun 2011 14:37
Just to clarify, @Van B's method will run quicker and the inaccuracy is so minimal that it's not worth worrying about in most cases.

@Phaelax's method is the 'correct' method but if you are trying to make your game run quicker and the small inacuracy is not worth worrying about then stick to @Van B's.

GregA
13
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 29th Jun 2011 14:57
I am precomputing the whole thing and putting the results in an array. Fastest method yet
baxslash
Valued Member
Bronze Codemaster
18
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jun 2011 15:05
Quote: "I am precomputing the whole thing and putting the results in an array. Fastest method yet"

Of course, you're storing the data anyway aren't you. Nice.

Even quicker you could save the answers to a text file and then copy the text into your code...?

Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 29th Jun 2011 15:52 Edited at: 29th Jun 2011 15:53
Nothing ever is free, so look up solution just shifts the burden onto the memory fetch cost. Storing in a DBPRO array might not be as quick as in mem block for example, or pointer.

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 29th Jun 2011 16:05
but in the end, sacrificing speed for simplicity is often the best way to go

(http://forum.thegamecreators.com/?m=forum_view&t=186382&b=1)


Why does blue text appear every time you are near?
GregA
13
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 29th Jun 2011 16:20 Edited at: 29th Jun 2011 16:21
For those of you wondering...

My whole purpose here is to drive kinematic objects in Dark Physics with animation scripts rather than make a bunch of little machines. Couple of reasons for this... One my levels are designed that way, and two my machines don't need to be proper physics machines, they just need to move a little bit from time to time.

The whole animation table gets precomputed at beginning of program. As of now, I am nuking the "roll my own" bit and doing it all in enhanced animation... Which has its own internal data structure. But anyhow, I am baking (making a keyframe for every frame of the animation) the animation script when the program launches, then just calling the enhanced animation functions to get the bits of data that I need from each frame.... x, y, z, yaw, pitch, roll. to animate kinematic objects in response to certain events.

@above

Truth.
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 29th Jun 2011 17:07
Quote: "DBPro is pretty consistant with angles and stuff."


Except for the 3D math commands

Sven B

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Jul 2011 19:41
That's why I recently added some commands to convert vector3 values between radians and degrees and vice versa. I also added single-value conversions too of DEGTORAD and RADTODEG.

Login to post a reply

Server time is: 2025-05-31 02:03:12
Your offset time is: 2025-05-31 02:03:12