Hi everyone. Brand new to Processing. I’m working my way through the Make: Getting Started with Processing book, and I was wondering about radians vs. degrees.
Is there an advantage to using one over the other? Does one compile/process faster than the other? Or is it just what one is comfortable with.
Apologies in advance if this is a super-naive question or if it’s in the wrong place, but like I said I’m brand new to this!
In general, it’s your preference. Some people like to think about angles in degrees and others, in radians. There might be a performance difference, I’m not sure, but it’s probably not enough to worry about.
I wouldn’t be concern too much about performance. Most functions in math work with radians but who knows what happens under the hood. They probly use Taylor expansions or trig tables to get you the result. If you are a brand new programmer, you should understand both. It is not difficult. I can tell you I find degrees more natural since this is what I used the most in my Math classes. However, radians turns out to be the same thing as degrees. It just happens that people do not speak radians. For instance, in skating, if you do a half turn, people will describe it like an 180 deg flip but nobody will say it is a pi radians flip. Degrees is simply more common and natural.
In a nutshell, if you know how to convert a number from radians to degrees or vise-versa, you are doing great (not cheating… do you know how to do it manually?). Notice Processing offers two functions for these conversions: degrees() and radians() (Documentation in the reference). The only think to keep in mind is to watch for functions working with angles as they will have a strict requirement to use a specific unit.
One clarification we should make… are you’re using Processing or p5.js? I had assumed p5.js because of the selected category (p5.js / Beginners). In p5.js, most people use use angleMode() to switch between degrees and radians globally, but in Processing, you use the degrees() and radians() functions.
Conversion to and from degrees isn’t a big deal, but if you want to write the most concise code without converting, you may find yourself doing it in radians, because Processing is thinking in radians under-the-hood.