Radians vs. degrees

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!

Thanks in advance,
Paul

1 Like

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.

Kf

1 Like

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.

1 Like

Again, apologies if I posted in the wrong place - the site is a tad overwhelming to start :slight_smile:

Thanks for the feedback. I will cease being concerned about which one to use.

I am guessing that you are using Processing (Java) – not p5.js (JavaScript).

In Processing, you can use whichever you prefer. But:

The built-in rotate methods – rotate(), rotateX(), rotateY(), rotateZ() – all take radians by default.

https://processing.org/reference/rotate_.html

They are common to use with the constants that are fractions of PI (QUARTER_PI, HALF_PI, PI, TWO_PI, TAU).

https://processing.org/reference/PI.html

In addition, the built-in PVector returns its angle results in radians by default.

https://processing.org/reference/PVector_fromAngle_.html

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.

1 Like