We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone,
So I'm doing some work with angles/trigonometry, but for some reason angleMode(DEGREES); does absolutely nothing. If I run angleMode(DEGREES); Math.sin(90); in the console I got the value of sin(90 radians) instead of the value for degrees.
Answers
just use
;-)
That doesnt seem to work for sin(radians(180)); where you'd expect 0 but you get '1.2246467991473532e-16'
I think that's okay, that's only when you print it out
To remove digits from a floating-point number, use the int(), ceil(), floor(), or round() functions.
https://www.processing.org/reference/
here is an example for sin(radians(180));
Chrisir
[EDITED]
That seems to be processing code, not p5.js code, but regardless it just doesn't work. Also, I can't use rounding as it would be inconsistent: through some magic or dumb luck things have now magically changed and the values are close to correct but not quite: sin(radians(180)) gives 0.0548036651... while cos(radians(180)) gives 0.9984971...
interesting
probably rounding errors or so
I dunno
;-)
https://Forum.Processing.org/two/discussions/tagged?Tag=anglemode()
An online p5.js sketch using angleMode() in DEGREES: :bz
http://Bl.ocks.org/GoSubRoutine/a117ecb16a8b0f939a190f87d3a13267
https://KhanAcademy.org/computer-programming/3d-tutorial-4/1648921303