Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lerp interpolates the wrong way? #164

Closed
gilgamec opened this issue Aug 24, 2021 · 6 comments · Fixed by #178
Closed

lerp interpolates the wrong way? #164

gilgamec opened this issue Aug 24, 2021 · 6 comments · Fixed by #178

Comments

@gilgamec
Copy link

I guess I've never had occasion to use it, but I just noticed that lerp (in Additive) works the opposite way of any other lerp implementation I've seen. (A brief Googling supports this; see C++, GLSL, Unity, Processing.) I'd expect that

lerp t a b = a + t * (b - a);

that is, that lerp 0 a b == a and lerp 1 a b == b, and that is the case in all other implementations. However, the implementation in linear is the opposite of this, i.e. lerp 0 a b == b and lerp 1 a b == a.

Is this mismatch intentional? If so, can it be clearly documented? If not, might it be fixed? I understand that it's longstanding at this point, but maybe something can be done.

@RyanGlScott
Copy link
Collaborator

I agree that this is a bit counterintuitive. Moreover, the slerp function uses the opposite convention, where slerp a b 0 = a and slerp a b 1 = b.

Unfortunately, the lerp function is pretty widely used, so I'd feel a bit remorseful about changing the convention all of a sudden. I'd say the best thing to do is to just document this.

@gilgamec
Copy link
Author

gilgamec commented Oct 5, 2021

I'd say the implementation is more than just counterintuitive, it's downright wrong. Like I said, every version I've ever used or could find does it the other way around; so if even the other interpolation function from linear does it that way, I'd say it's clearly a bug and should at least be documented as such.

(I note both functions were written by @ekmett; maybe he has a higher purpose, but I'd guess the lerp implementation is just a longstanding typo.)

@mrehayden1
Copy link

Agreed. Can this not be made much clearer in the documentation?

I had some very jittery animations until I figured this out. It defies all my intuition to defined it this way!

@ekmett
Copy link
Owner

ekmett commented Mar 27, 2024

This was a complete brainfart on my part. I'm surprised it has stood this long.

@ekmett
Copy link
Owner

ekmett commented Mar 27, 2024

I'd be open to a major version bump and clear CHANGELOG entry and fixing this.

RyanGlScott added a commit that referenced this issue Apr 15, 2024
To test the fix for #164.
@RyanGlScott
Copy link
Collaborator

I've uploaded linear-1.23 to Hackage with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants