Reputation: 373
There is a function angleMode(mode); in P5 documentation that sets mode either RADIANS or DEGREES but I can't figure out how to use it or how to draw in polar coordinates in p5.js. Does anybody know how to do it with p5.js?
Upvotes: 0
Views: 2063
Reputation: 175
angleMode()
changes wheter p5.js interprets your angle values as radians and degrees. It has no impact on the way drawing is done.
You can just use trigonometric functions to translate between polar and cartesian.
var x = r * cos(angle)
var y = r * sin(angle)
point(x, y);
If you need more information, you can see this example in p5.js documentation: https://p5js.org/examples/math-polartocartesian.html
The coding train also has a video tutorial on this: https://www.youtube.com/watch?v=N633bLi_YCw
Upvotes: 2
Reputation: 3872
RADIANS
and DEGREES
are the constants like 0 and 1. Therefore:
angleMode(DEGREES);// sets the mode
Upvotes: 0