processing / p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
http://p5js.org/
GNU Lesser General Public License v2.1
21.14k stars 3.23k forks source link

Feature: Add function to get the principal value of angles #5893

Open EshaanAgg opened 1 year ago

EshaanAgg commented 1 year ago

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?

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.

welcome[bot] commented 1 year ago

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!

EshaanAgg commented 1 year ago

I would love to work on this issue.

Shubham1450 commented 1 year ago

Please assign this issue to me.

infusion commented 1 year ago

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

Qianqianye commented 1 year ago

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.

limzykenneth commented 1 year ago

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.

Qianqianye commented 9 months ago

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.

Vishal2002 commented 6 months ago

@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 commented 6 months ago

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

limzykenneth commented 6 months ago

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

Vishal2002 commented 5 months ago

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?