-
Notifications
You must be signed in to change notification settings - Fork 9
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 scalar angle multiplication #815
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,6 +300,20 @@ object Angle extends AngleOptics { | |
def -(a: Angle): Angle = | ||
Angle.fromMicroarcseconds(toMicroarcseconds - a.toMicroarcseconds) | ||
|
||
/** | ||
* Scalar multiplication of this angle and and natural number `a`. Exact | ||
* @group Operations | ||
*/ | ||
def *(a: Long): Angle = | ||
Angle.fromMicroarcseconds(toMicroarcseconds * a) | ||
|
||
/** | ||
* Scalar multiplication of this angle and double precission number `a`. Approximate | ||
* @group Operations | ||
*/ | ||
def *?(a: Double): Angle = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We just document it when it's inexact. Pretty much anything involving There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reverted to |
||
Angle.fromMicroarcseconds((toMicroarcseconds * a).toLong) | ||
|
||
/** | ||
* This angle as an Offset.P. Exact, invertible. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this overflows when
a
gets large. You may need to go toBigDecimal
and renormalize it back into 0..360° before constructing the return value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I pushed a new commit doing as you suggest and some tests