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

Use a dedicated Angle type for angles instead of Length<Rad>. #243

Merged
merged 1 commit into from Dec 7, 2017

Conversation

@nical
Copy link
Collaborator

nical commented Dec 7, 2017

This is the other breaking change that I want to sneak in @SimonSapin's bump.

Length has proved quite unergonomic for angles. We don't have a good use case for storing angles in degrees (that would be evil), and there could be a lot useful specific methods for methods that apply for angles but not lengths.

With a dedicated angle type we can write things like:

mat.pre_rotate(Angle::radians(PI));
mat.pre_rotate(Angle::degrees(90.0));

which deals with degrees in a nicer way (everything is always stored in radians but conversion to and from is easy).
Also, with Angle we can implement Angle<T> / Angle<T> = T to compute ratios, multiply angles by these ratios, etc.

I ran into the (lack of) ergonomics with Length<Rad> a lot in the SVG logic in lyon.


This change is Reviewable

@nical nical force-pushed the nical:angle branch from cf2bf66 to ff9b61c Dec 7, 2017
@nical
Copy link
Collaborator Author

nical commented Dec 7, 2017

r? @kvark

@kvark
kvark approved these changes Dec 7, 2017
Copy link
Member

kvark left a comment

looks sensible

@kvark
Copy link
Member

kvark commented Dec 7, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Dec 7, 2017

📌 Commit ff9b61c has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Dec 7, 2017

Testing commit ff9b61c with merge 58904ae...

bors-servo added a commit that referenced this pull request Dec 7, 2017
Use a dedicated Angle type for angles instead of Length<Rad>.

This is the other breaking change that I want to sneak in @SimonSapin's bump.

Length has proved quite unergonomic for angles. We don't have a good use case for storing angles in degrees (that would be evil), and there could be a lot useful specific methods for methods that apply for angles but not lengths.

With a dedicated angle type we can write things like:
```rust
mat.pre_rotate(Angle::radians(PI));
mat.pre_rotate(Angle::degrees(90.0));
```
which deals with degrees in a nicer way (everything is always stored in radians but conversion to and from is easy).
Also, with Angle we can implement `Angle<T> / Angle<T> = T` to compute ratios, multiply angles by these ratios, etc.

I ran into the (lack of) ergonomics with `Length<Rad>` a lot in the SVG logic in lyon.

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

bors-servo commented Dec 7, 2017

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

@bors-servo bors-servo merged commit ff9b61c into servo:master Dec 7, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@nical nical mentioned this pull request Dec 8, 2017
bors-servo added a commit that referenced this pull request Dec 8, 2017
Implement Neg for Angle.

I forgot to implement Neg in #243.

<!-- 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/246)
<!-- Reviewable:end -->
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.