p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

Feature: Add function to get the principal value of angles

Open EshaanAgg opened this issue 2 years ago • 11 comments

Increasing Access

While using angles in mathematical and geometric constructions, we often want the angle to be in the principal range i.e. from -180 to 180 degrees (or -PI to PI in radians). We can implement one such utility method.

Most appropriate sub-area of p5.js?

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

Feature request details

The method can be added with documentation in the src/math/trignometry.js file so that he conversion takes place after detecting the current angle mode.

Can also be complemented with another boolean function isPrincipalArgument() to check the same.

EshaanAgg avatar Dec 11 '22 13:12 EshaanAgg

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

welcome[bot] avatar Dec 11 '22 13:12 welcome[bot]

I would love to work on this issue.

EshaanAgg avatar Dec 11 '22 13:12 EshaanAgg

Please assign this issue to me.

Shubham1450 avatar Dec 12 '22 18:12 Shubham1450

The question is, if this is something p5.js should do, or rather another library such as Angles.js with its method normalizeHalf(x): https://www.npmjs.com/package/angles

infusion avatar Dec 13 '22 03:12 infusion

Thank you @EshaanAgg for opening this issue. I am inviting more Math stewards to this discussion @limzykenneth, @jeffawang, @AdilRabbani. Would love to hear what y'all think.

Qianqianye avatar Dec 13 '22 05:12 Qianqianye

I can understand the straightforward appeal of implementing this but wouldn't it be sufficient to offset the angle values used in your sketch by +180 degrees or +PI before passing them to p5.js functions?

The main thing for me here is the utility aspect of this feature as well as how this feature increases access. I would recommend fleshing out the feature more in this issue first before thinking about the PR or actual code implementation.

limzykenneth avatar Dec 13 '22 22:12 limzykenneth

Thank you all for working on this issue. I am inviting the current Math stewards to this discussion @limzykenneth, @ericnlchen, @ChihYungChang, @bsubbaraman, @albertomancia, @JazerUCSB, @tedkmburu, @perminder-17, @Obi-Engine10, @jeanetteandrews. Would love to hear what y'all think.

Qianqianye avatar Oct 13 '23 23:10 Qianqianye

@Qianqianye @davepagurek I think we should directly make a global function which we will be use in different trigonometric functions and that will directly check whether the given angle have radian value or principle value, that function directly change the radian to principle value.

Vishal2002 avatar Jan 06 '24 11:01 Vishal2002

@Qianqianye @limzykenneth Is it still a relevant feature or should we skip this for a while ?

Vishal2002 avatar Jan 11 '24 02:01 Vishal2002

For now my comment above still applies and this feature will still need a stronger case for inclusion before we can consider it.

limzykenneth avatar Jan 11 '24 09:01 limzykenneth

There are lots of function that takes both and works perfectly fine like we have the rotateZ function which takes both degree and radian angles.So do we really need this feature?

Vishal2002 avatar Jan 22 '24 18:01 Vishal2002