-
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
Conversation
c56bbe0
to
1d23bda
Compare
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I made it *?
to denote that is approximate. not sure if it is a good idea, WDYT?
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.
We just document it when it's inexact. Pretty much anything involving Double
is inexact by definition.
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.
I reverted to *
* @group Operations | ||
*/ | ||
def *(a: Long): Angle = | ||
Angle.fromMicroarcseconds(toMicroarcseconds * a) |
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 to BigDecimal
and renormalize it back into 0..360° before constructing the return value.
scala> Angle.Angle90 * 4000000
val res14: lucuma.core.math.Angle = 0
scala> Angle.Angle90 * 40000000
val res15: lucuma.core.math.Angle = 230290448384
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
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
We just document it when it's inexact. Pretty much anything involving Double
is inexact by definition.
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #815 +/- ##
==========================================
+ Coverage 78.64% 78.98% +0.33%
==========================================
Files 113 113
Lines 1494 1494
Branches 3 3
==========================================
+ Hits 1175 1180 +5
+ Misses 319 314 -5 ☔ View full report in Codecov by Sentry. |
No description provided.