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 useful methods to Angle. #247
Conversation
|
|
||
| pub fn two_pi() -> Self { Angle::radians(T::PI() + T::PI()) } | ||
|
|
||
| pub fn frac_pi_2() -> Self { Angle::radians(T::FRAC_PI_2()) } |
This comment has been minimized.
This comment has been minimized.
kvark
Dec 12, 2017
Member
Does the Angle have a semantic of radians? I thought of it as an abstracted opaque angle, in which case having pi in the name here is leaking that abstraction.
This comment has been minimized.
This comment has been minimized.
nical
Dec 12, 2017
•
Author
Collaborator
Angle exposes its internals as radians, I didn't try to abstract out the unit as much as just make the type more convenient (and explicit), while keeping some helpers to deal with degrees without too much hassle. Kinda like Transform3D being a matrix, Rotation3D a quaternion, etc.
I think that it's best if radians to are the first class citizen and I would rather be transparent about it than build an abstraction. But it doesn't go against picking names that are more "units agnostic" when convenient. Not sure what those could be for these constants, though. Do you have ideas?
|
@bors-servo r+ |
|
|
Add some useful methods to Angle. Part of the motivation for a dedicated angle type was to have this type of goodies. - `Angle::positive` returns the angle in the `[0 .. 2*PI[` range - `Angle::signed` returns the angle in the `]-PI .. PI]` range - a bunch of constructors with common constants (zero, pi, etc.) - sin_cos <!-- 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/247) <!-- Reviewable:end -->
|
|
nical commentedDec 8, 2017
•
edited by larsbergstrom
Part of the motivation for a dedicated angle type was to have this type of goodies.
Angle::positivereturns the angle in the[0 .. 2*PI[rangeAngle::signedreturns the angle in the]-PI .. PI]rangeThis change is