generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Why doesn't this work?

Previous Thread :: Next Thread 
GooeyChopsticks is not online. GooeyChopsticks
Joined: 25 Nov 2015
Total Posts: 632
01 Dec 2015 03:14 PM
local Lerp = function(Start, End, Increment)
return ((1 - Increment) * (Start + Increment) * End)
end

And do not tell me 'CFrame:lerp' because this function is for something else; I see no need in creating an extra CFrame just to tween.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
01 Dec 2015 03:16 PM
Try this:

local Lerp = function(Start,End,Delta)
return Start + (End - Start) * Delta
end
Report Abuse
GooeyChopsticks is not online. GooeyChopsticks
Joined: 25 Nov 2015
Total Posts: 632
01 Dec 2015 03:18 PM
That method isn't precise. I have a feeling that my )s ruined it. I want them there to keep it neat, but I am not exactly sure how this works and where to put them.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
01 Dec 2015 03:21 PM
Why isn't it precise?
Report Abuse
GooeyChopsticks is not online. GooeyChopsticks
Joined: 25 Nov 2015
Total Posts: 632
01 Dec 2015 03:22 PM
https://en.wikipedia.org/wiki/Linear_interpolation
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
01 Dec 2015 05:57 PM
Well then in your case this is what you'd do:

local Lerp = function(Start,End,Increment)
return (1 - Increment) * Start + Increment * End
end
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
01 Dec 2015 06:09 PM
What fish first posted is precise and succinct. If that isn't what you need, you aren't doing linear interpolation.
Report Abuse
GooeyChopsticks is not online. GooeyChopsticks
Joined: 25 Nov 2015
Total Posts: 632
01 Dec 2015 06:15 PM
@Casualist

No, straight from that article

'This method is imprecise and does not guarantee v = v1 when t = 1' or something along those lines. It said my method is the precise method. Now, fish, I realize that's the equation. But I wanted to add parentheses to make it look good; when I did so, it broke. Please add them?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Dec 2015 06:16 PM
Except that it does, moron.

(End - Start) * 1 = End - Start
Start + End - Start = End
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
01 Dec 2015 06:17 PM
Ispec, you always try to make code look pretty. Just do as they say or use mine which will work.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Dec 2015 06:18 PM
There is a lot of precision in floats that the "tiny margin of an error" (that much have resulted in there being an imprecision in the first place, because anything times 1 = anything) wouldn't probably cause any noticeable difference.
Report Abuse
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
01 Dec 2015 06:19 PM
^^^^^^^^^^

A floating-point arithmetic error means you're working with extraordinarily tiny numbers. You don't need to be precise, especially because ROBLOX rounds up to the thousandths in all of their vector values.
Report Abuse
GooeyChopsticks is not online. GooeyChopsticks
Joined: 25 Nov 2015
Total Posts: 632
01 Dec 2015 06:20 PM
@Cnt

I didn't realize that. I thought they meant that it would mess up the equation.

@Fish

Yes, I do like my code to be pretty.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Dec 2015 06:20 PM
"ROBLOX rounds up to the thousandths in all of their vector values."
Not true, just because it might be rounded in studio it doesn't mean it's actually stored like that.

print(Vector3.new(3.14e-10, 0, 0).X);
-- not 0
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
01 Dec 2015 06:23 PM
If you're dealing with something that requires that much precision why aren't you using the method they posted right under it? It's literally copy, paste, and adjust syntax:

float lerp(float v0, float v1, float t) {
return (1-t)*v0 + t*v1;
}

function lerp(v0, v1, t)
return (1-t)*v0 + t*v1;
end
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
01 Dec 2015 06:23 PM
@cntkillme Since you're here and online, care to explain why rayk999 was telling me that you were making fun of me in slack?
Report Abuse
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
01 Dec 2015 06:24 PM
Can you guys not...
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Dec 2015 06:24 PM
Which time? I'm sure I've made fun of you and everyone else on this forum and even on the slack team dozens of time.
Report Abuse
GooeyChopsticks is not online. GooeyChopsticks
Joined: 25 Nov 2015
Total Posts: 632
01 Dec 2015 06:25 PM
@Casualist

I am, I am literally asking where do I put the parentheses. I want it to look nice with them, but when I did, it broke it.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
01 Dec 2015 06:28 PM
Dude learn the Order Of Operations...

Don't try to make it look pretty, just do what works.
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
01 Dec 2015 06:28 PM
((1 - Increment) * (Start + Increment) * End)

This is fundamentally different than linear interpolation. This is not a parathesis issue. It isn't close to the same equation.



It should look like this
(1-Increment)*Start + Increment*End

while is equivalent to:
Start -Increment*Start + Increment*end
While can be factored to:
Start + Increment*(End-Start)
Report Abuse
GooeyChopsticks is not online. GooeyChopsticks
Joined: 25 Nov 2015
Total Posts: 632
01 Dec 2015 06:30 PM
I know, my parentheses were in the wrong spot.
And @fish don't act like I don't know PEMDAS, I am not stupid.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
01 Dec 2015 06:31 PM
PEMMDAS*

The other M is modulo

Also, I am sure you do but you choose to make it look pretty when it just won't work. Don't go for making it pretty; go for making it work as good as it can.
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
01 Dec 2015 06:33 PM
>>This is not a parathesis issue. It isn't close to the same equation.
"I know, my parentheses were in the wrong spot."

wut
Report Abuse
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
01 Dec 2015 06:35 PM
"PEMMDAS"

I googled that and it didn't even come up as a real concept, it shows pictures of ROBLOX scripting tutorials.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image