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.

AppGameKit Classic Chat / Lerp or Linear Interpolation question.

Author
Message
Stormwire
14
Years of Service
User Offline
Joined: 3rd Sep 2010
Location:
Posted: 15th Jan 2012 08:49 Edited at: 15th Jan 2012 08:50
I have the Lerp function working but I was wondering if anyone could tell me how I can get more points between the two initial points so I can draw an actual line and not just dots. Right now it is always 10 points no matter how far away the points are from each other. I know why this is but what I am looking for is how to add more points and take away points depending on how far the two initial points are from each other. So the closer they are the less points you would need to draw a line and the further the more points you would need. Any help is appreciated

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Jan 2012 10:33
I would divide the overall distance by your maximum distance between segments and use the answer as your "step" amount in the "for" loop at the start. Hope that makes sense?

Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 15th Jan 2012 10:50
This will calculate how many points you need to make a line.


This will draw a line using one sprite.

Snippets from my vector draw code, not tested, just made here but should work.

best regards Preben Eriksen,
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 15th Jan 2012 18:16
It's not AppGameKit code but if you understand darkbasic professional there's a video tutorial at http://forum.thegamecreators.com/?m=forum_view&t=192286&b=1 you can view that for the basic code and convert it to AppGameKit easily enough. when I've got a moment I'll get around to it myself.
Stormwire
14
Years of Service
User Offline
Joined: 3rd Sep 2010
Location:
Posted: 16th Jan 2012 11:01
@baxslash:

Thanks I think what your saying is what Preben wrote? You wrote something similar in Daniels UFC thread.

@Preben:

Works perfect and your line function is a great share. Cheers for that You got a good resource for this kind of thing?

@Daniel TGC:

Your tutorial is what got me started on this lol I wanted to try the Linear instead of the Cosine interpolation since it looked easier but I got stuck on figuring out the actual number of dots needed.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Jan 2012 11:19
Quote: "Thanks I think what your saying is what Preben wrote? You wrote something similar in Daniels UFC thread."

Yes that's more or less what I meant.

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th Jan 2012 11:59
Quote: "For i# = 0.0 To 1.0 Step 0.1"

The "Step 0.1" will produce 10 points, make this number smaller for more points.

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2024-11-23 00:37:44
Your offset time is: 2024-11-23 00:37:44