IDMNYU / p5.js-func

Function Generators for p5.js
MIT License
126 stars 10 forks source link

Angle-based functions broken when using angleMode(DEGREES) #3

Closed kyeah closed 2 years ago

kyeah commented 2 years ago

Hello! I was attempting to use one of the angle-based functions, like ease.backInOut, and realized the values are incorrect when the sketch has the angleMode set to DEGREES.

Our workaround for now has been to set angleMode(RADIANS) before calling p5.func functions:

angleMode(RADIANS)
let val = ease.backInOut(t)
angleMode(DEGREES)

But this was a tricky issue to debug.

Possible Resolution

Ideally the library would probably use the core JS functions, Math.sin and Math.cos, directly instead of the p5 equivalents, which are dependent on the user-defined angleMode.

Doesn't seem like there's any other easy way to work around this issue, since:

Thanks!

rev3rend commented 2 years ago

oh wow. did a new version of p5 change their default angleMode()? happy to flip all the cos()/sin() calls to use the core math library. that's an easy fix.