|
| 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 |
|
|
|
| 01 Dec 2015 03:16 PM |
Try this:
local Lerp = function(Start,End,Delta) return Start + (End - Start) * Delta end |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 01 Dec 2015 03:22 PM |
| https://en.wikipedia.org/wiki/Linear_interpolation |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|