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

Replace hypot() in calculation.js with Math.hypot() #6536

Closed
1 of 17 tasks
GregStanton opened this issue Nov 7, 2023 · 7 comments · Fixed by #6537
Closed
1 of 17 tasks

Replace hypot() in calculation.js with Math.hypot() #6536

GregStanton opened this issue Nov 7, 2023 · 7 comments · Fixed by #6537

Comments

@GregStanton
Copy link
Collaborator

GregStanton commented Nov 7, 2023

Increasing Access

Currently, calculation.js contains about 40 lines of code that are no longer necessary due to browser updates. Removing unnecessary complexity makes it easier for contributors to work with the codebase.

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build Process
  • Unit Testing
  • Internalization
  • Friendly Errors
  • Other (specify if possible)

Feature enhancement details

Problem:
The hypot() function was added to calculation.js in 2016. Its job is to call the native Math.hypot() if it's supported and to provide a fallback function if not. At the time, Math.hypot() was relatively new, but it's now been widely supported for close to a decade and is already used directly in 3d_primitives.js, interaction.js, and p5.Camera.js. The hypot() code now adds unnecessary complexity and performs an unnecessary check every time dist() or mag() is called (these functions call hypot() internally).

Solution:
Remove hypot() from calculation.js and replace calls to it (from the definitions of dist()) and mag()) with calls to Math.hypot().

@Garima3110
Copy link
Member

Hey @GregStanton I would like to work on this issue.
Thank you..!

@GregStanton
Copy link
Collaborator Author

That's great @Garima3110! Thank you!

@diyaayay
Copy link
Contributor

diyaayay commented Nov 8, 2023

Hey @GregStanton
I would like to work on this issue.
Thankyou.

@GregStanton
Copy link
Collaborator Author

Thanks @diyaayay! I left a review. Just waiting on the maintainers now to take the next steps.

@limzykenneth
Copy link
Member

Thanks @diyaayay for the PR. Just want to note that @Garima3110 had indicated intention to fix this first and my preference is to allow people to take their time working on an issue without needing to worry about getting it done quickly. In the future I would prefer prioritizing those who has indicated intention to work on an issue and defer until the original contributor indicated they are no longer willing to work on it or if sufficient time has passed (at least one month). Thanks!

@diyaayay
Copy link
Contributor

diyaayay commented Nov 9, 2023

Hey @limzykenneth , Thankyou for letting me know. This was my first time at open source contributions. Will surely keep the code of conduct from now onwards. Thanks!

@Garima3110
Copy link
Member

Thanks @diyaayay for the PR. Just want to note that @Garima3110 had indicated intention to fix this first and my preference is to allow people to take their time working on an issue without needing to worry about getting it done quickly. In the future I would prefer prioritizing those who has indicated intention to work on an issue and defer until the original contributor indicated they are no longer willing to work on it or if sufficient time has passed (at least one month). Thanks!

Thanks @limzykenneth !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants