Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement linear interpolation for some of the types. #203
+97
−0
Conversation
|
r? @kvark |
| where T: Copy + One + Add<Output=T> + Sub<Output=T> + Mul<Output=T> { | ||
| /// Linearly interpolate between this length and another length. | ||
| /// | ||
| /// `t` is expected to be between zero and one. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nical
Jun 1, 2017
Author
Collaborator
I'd rather not. [0..1] is the range that "makes sense" but going beyond is common when when animating things that give a "spring" kind of effect (like the common over-scroll effects on mac). I don't know how to phrase that in a succinct way in the comment, but for most use use cases the interval [0..1] is the one that makes most sense.
|
@bors-servo r+ |
|
|
bors-servo
added a commit
that referenced
this pull request
Jun 1, 2017
Implement linear interpolation for some of the types. I am converting code that uses euclid to 0.14, and a pattern that often comes up is interpolating between two points, which used to be simple to write but has become a bit more tedious now that addition between point and point isn't implemented anymore. This implements `lerp(&self, Self) -> Self` for points, and for the sake of consistency, added vectors, size, rectangles and length. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/203) <!-- Reviewable:end -->
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
nical commentedJun 1, 2017
•
edited by Manishearth
I am converting code that uses euclid to 0.14, and a pattern that often comes up is interpolating between two points, which used to be simple to write but has become a bit more tedious now that addition between point and point isn't implemented anymore.
This implements
lerp(&self, Self) -> Selffor points, and for the sake of consistency, added vectors, size, rectangles and length.This change is