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

Implement linear interpolation for some of the types. #203

Merged
merged 1 commit into from Jun 1, 2017

Conversation

@nical
Copy link
Collaborator

nical commented Jun 1, 2017

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.


This change is Reviewable

@nical
Copy link
Collaborator Author

nical commented Jun 1, 2017

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.

@kvark

kvark Jun 1, 2017

Member

let's lift this expectation from a comment to a real debug_assert

This comment has been minimized.

@nical

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.

@kvark
Copy link
Member

kvark commented Jun 1, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jun 1, 2017

📌 Commit 7be629d has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Jun 1, 2017

Testing commit 7be629d with merge a023967...

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 -->
@kvark
kvark approved these changes Jun 1, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Jun 1, 2017

☀️ Test successful - status-travis
Approved by: kvark
Pushing a023967 to master...

@bors-servo bors-servo merged commit 7be629d into servo:master Jun 1, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.