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

Add scalar angle multiplication #815

Merged
merged 2 commits into from
Oct 2, 2023
Merged

Conversation

cquiroz
Copy link
Collaborator

@cquiroz cquiroz commented Oct 2, 2023

No description provided.

@tpolecat tpolecat changed the title Add scala angle multiplication Add scalar angle multiplication Oct 2, 2023
@cquiroz cquiroz force-pushed the scalar-angle-multiplication branch from c56bbe0 to 1d23bda Compare October 2, 2023 19:38
* Scalar multiplication of this angle and double precission number `a`. Approximate
* @group Operations
*/
def *?(a: Double): Angle =
Copy link
Collaborator Author

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?

Copy link
Member

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.

Copy link
Collaborator Author

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)
Copy link
Member

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

Copy link
Collaborator Author

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 =
Copy link
Member

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-commenter
Copy link

codecov-commenter commented Oct 2, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (d108bec) 78.64% compared to head (942b878) 78.98%.
Report is 16 commits behind head on master.

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     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cquiroz cquiroz merged commit 614bf74 into master Oct 2, 2023
8 checks passed
@cquiroz cquiroz deleted the scalar-angle-multiplication branch October 2, 2023 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants