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 / Linear, Cosine, and Cubic Interpolation

Author
Message
Twisted Steel Software
17
Years of Service
User Offline
Joined: 21st May 2007
Location: Teh Interwebs
Posted: 20th Apr 2010 18:42
Hey all.

It's been forever since I've been here. Interpolation is the one thing I never got 'round to learning, so I decided to come back to DBP to learn the basic math things I should already know >.>

So I have two functions so far. One works for positive numbers (and as it approaches 0, the line's dots I draw spread out until finally drawing none past negative), the other draws on X only, as if the CosLerp function isn't returning a value. I have no idea what's going on here, but I seem to be having all kinds of issues.

Lerp:


CosLerp:


Whole thing:


Your signature has been erased by a mod - Please change your "moddy freak out" size to 600x240px. Thanks
Dr Tank
16
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 20th Apr 2010 18:52
In DBP, trig functions are in degrees.

Twisted Steel Software
17
Years of Service
User Offline
Joined: 21st May 2007
Location: Teh Interwebs
Posted: 20th Apr 2010 18:54
o.O?! Oh are you f.. So I have to convert the cos from degrees to radians? Time to google it! xP

Will post back if I succeed or not

Your signature has been erased by a mod - Please change your "moddy freak out" size to 600x240px. Thanks
Twisted Steel Software
17
Years of Service
User Offline
Joined: 21st May 2007
Location: Teh Interwebs
Posted: 20th Apr 2010 19:02
Yeah, that's not the problem. I pass in 1 as x in CosLerp, and I get 0 when a and b are 0,100

Maybe I should just do it in C instead...

Thanks for the fast answer, btw, Dr Tank

Your signature has been erased by a mod - Please change your "moddy freak out" size to 600x240px. Thanks
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Apr 2010 19:11 Edited at: 20th Apr 2010 19:11
You're not using correct syntax. The correct way to return a float in DBPro is like this (taking into account that dbpro uses degrees):


Twisted Steel Software
17
Years of Service
User Offline
Joined: 21st May 2007
Location: Teh Interwebs
Posted: 20th Apr 2010 19:27 Edited at: 20th Apr 2010 19:40
OH RIGHT! The # sign! I totally forgot x.x I've got it working in C++.. figured it was a type issue. I'm so used to strictly defining types..

Much thanks to the both of you!

Now of course.. onto more trigonometry that I never bothered trying to learn way back when xP

Let's say I want to draw a circle by hand by specifying the dots.

is ringing a bell, though I doubt I got it right. o.o

I'm assuming if I just sat down here.. and if that circle was right.. I could make a camera orbit a point finally!


[EDIT]So, here's what we have. The DBP version still has the issue of closer to 0, the dots become more sparse and when negative, they no longer draw (and just to add to the confusion, the C++ version works flawlessly with negative values and approaching 0).

DBP:


C++:


Your signature has been erased by a mod - Please change your "moddy freak out" size to 600x240px. Thanks
Dr Tank
16
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 20th Apr 2010 19:35

Login to post a reply

Server time is: 2025-05-07 08:26:13
Your offset time is: 2025-05-07 08:26:13