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 / Cosine interpolation

Author
Message
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 22nd Jun 2004 19:56
Hi,

I was wondering if anybody could figure this out. I'm trying to get simple cosine interpolation working between two points (x1,y2)(x2,y2).

This is what I have:



Which basically boils down to my equation for interpolation being

mu# = [value between 0.0 and 1.0]
mu2# = (1-cos(mu#*(3.1412)))/2
interpolatedy# = (y1*(1-mu2#)+(y2*mu2#))


Yet I get returned the original y1 value. Anybody help (doubt it, bit of a niche this)?

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jun 2004 20:16
Try this. Function interpolates from A to B based on mu#. (0-1)



As for cosine interpolation, I have no idea what that is.

"eureka" - Archimedes
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 22nd Jun 2004 20:24
Quote: "As for cosine interpolation, I have no idea what that is."


It's basically interpolating but to gain a smoother curve between points. It's based on, apparently, chaning the value of mu# to this:

mu2# = (1-cos(mu#*(3.1412)))/2

And then running a normal interpolation.

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
las6
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 22nd Jun 2004 21:02
I think I did cosine interpolation once. that one isn't really good for just about anything. In 2d, it behaves somewhat normally (not good or predictable) - but when used alone in 3d it's just like linear interpolation with a slow movement at the start and the end of the line... :\

You're much better of with real splines. Beziers, preferably. Hermite or Cubic Interpolations are good...


| Keyboard not detected. Press F1 to continue. |
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 22nd Jun 2004 21:09
Quote: "I think I did cosine interpolation once. that one isn't really good for just about anything. In 2d, it behaves somewhat normally (not good or predictable) - but when used alone in 3d it's just like linear interpolation with a slow movement at the start and the end of the line... :\"


I'm interested in 2d at the moment

I remember now, you did that path making app. Do you still have the code you used?

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.
las6
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 22nd Jun 2004 21:46 Edited at: 22nd Jun 2004 21:50
here's what I found:
and like for linear interpolation, you'll have to do these separately for x and y.
(dunno why I have used "y#" as the generic variable... could have used a# b# c# d# like for the linear one...



and treat that y1# as the start point and y2# as the end point in cubic and hermite interpolations... y0# is the point before that or just a separate control point you can use to change the curve behaviour. y3# is the point after the end point or a control point just like y0#.

there's a easier way now. Just store all the data in vectors and use the interpolation from the vector commands. (there's a working hermite right in there - very easy to use)


| Keyboard not detected. Press F1 to continue. |
las6
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 22nd Jun 2004 21:51
here's the better alternative, I think:
http://www.dannywartnaby.co.uk/rgt/index.php?board=8;action=display;threadid=3408


| Keyboard not detected. Press F1 to continue. |
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 22nd Jun 2004 22:29
Cheers

Two strings walk into a bar. I'll have a pint says the first$%ASLDJ09920D"$"$D. Excuse my friend says the second, he isn't null terminated.

Login to post a reply

Server time is: 2025-05-23 05:39:55
Your offset time is: 2025-05-23 05:39:55