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 Discussion / curvevalue ...Questions.

Author
Message
Julian Spillane
22
Years of Service
User Offline
Joined: 2nd Feb 2003
Location:
Posted: 3rd Feb 2003 06:44
*laughs* Once again I have a question. *grins sheepishly* Anyways, I was wondering if anyone knew the mathematics behind the curvevalue function. I know that the result can be obtained through SLERP (Quaternion math), but I'm wondering if there's any trigonometric way in which it can be replicated.

Regardless, does anyone know how the DB crew implemented it?

Thanks in advance!
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 3rd Feb 2003 14:38
I don't think you need trigonometry for this, just simple arithmetic.

I believe the formula maybe:
n = current + (destination - current) / speed

so something like:
n# = curvevalue(480.0, n#, 30.0)

would translate to:
n# = n# + (480.0 - n#) / 30.0

Perhaps Lee or Rich can confirm this for us

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 3rd Feb 2003 17:27
...and before you post asking about Wrapvalue(), I'll save you a bit of time

To keep an angle in range of 0 and 360, it's not a simple matter of adding or subtracting 360 from a value if it goes out of range. You need to take into account how many times you have to do this. You could do this in a loop, but that would waste processing time.

This example should show how it's done:


Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 3rd Feb 2003 21:13
Curveangle does this: wrapvalue(curvevalue()), just the same thing as curvevalue, but keeping it within 360 degrees for angle processing. I think.

Once I was but the learner,
now, I am the Master.
Julian Spillane
22
Years of Service
User Offline
Joined: 2nd Feb 2003
Location:
Posted: 4th Feb 2003 00:07
Thanks a lot, guys. *laughs* Yeah, I knew how wrapvalue works.

See, I've been bored and randomly pondering whether or not it would be possible to optimize these commands any further, but..they look pretty solid mathematically. Not really very processor intensive.

Well, thanks for your help!

Login to post a reply

Server time is: 2025-08-08 11:45:03
Your offset time is: 2025-08-08 11:45:03