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 upAdd some swizzling methods to vectors and points. #220
+82
−6
Conversation
|
r? @nox |
|
@bors-servo r+ |
|
|
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 -->
|
|
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 commentedJul 3, 2017
•
edited
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