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

Add some swizzling methods to vectors and points. #220

Merged
merged 1 commit into from Jul 3, 2017

Conversation

@nical
Copy link
Collaborator

nical commented Jul 3, 2017

This adds a few swizzling methods such as point2.xy() and more explicit ways to project from 3d to 2d (point3.xy(), point3.xz(), etc.).

Having a shorthand to swap x and y is useful to get a tangent vector or to avoid duplicating code in places where there the x/y symmetry can be exploited (for example lyon's y-monotone cubic curves use the x-monotone implementation after swapping x and y).

The added 3d to 2d projections offer a less error-prone alternative to to_2d() (which we could remove next time we have a breaking change to make), and make it convenient to project on more than the xy plane.

There are plenty of other swizzling combinations we could add (point.xx(), point.yxz(), etc.) but I'd rather add them whenever/if there is a need for them.


This change is Reviewable

@nical
Copy link
Collaborator Author

nical commented Jul 3, 2017

r? @nox

@nox
Copy link
Member

nox commented Jul 3, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jul 3, 2017

📌 Commit dbb6cee has been approved by nox

@bors-servo
Copy link
Contributor

bors-servo commented Jul 3, 2017

Testing commit dbb6cee with merge c40f6b0...

bors-servo added a commit that referenced this pull request Jul 3, 2017
Add some swizzling methods to vectors and points.

This adds a few swizzling methods such as `point2.xy()` and more explicit ways to project from 3d to 2d (`point3.xy()`, point3.xz(), etc.).

Having a shorthand to swap x and y is useful to get a tangent vector or to avoid duplicating code in places where there the x/y symmetry can be exploited (for example lyon's y-monotone cubic curves use the x-monotone implementation after swapping x and y).

The added 3d to 2d projections offer a less error-prone alternative to `to_2d()` (which we could remove next time we have a breaking change to make), and make it convenient to project on more than the xy plane.

There are plenty of other swizzling combinations we could add (point.xx(), point.yxz(), etc.) but I'd rather add them whenever/if there is a need for them.

<!-- 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/220)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 3, 2017

☀️ Test successful - status-travis
Approved by: nox
Pushing c40f6b0 to master...

@bors-servo bors-servo merged commit dbb6cee into servo:master Jul 3, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@nical nical deleted the nical:swizzling branch Jul 3, 2017
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.