Hey! Always thought that C++/openFrameworks dealt everything (at least most?) stuff in degrees and been using degrees for a while without any issues for things like laying out stuff in polar coordinates. Today, noticing that there was some erratic behaviour on a new piece of code, it looked like degrees wasn’t working and voila, ofDegToRad fixed it.

Just for future reference, what’s in degrees and what’s in radians?

For example, if I want to lay down a bunch of circles in a circular layout, at every 10 degree intervals, which one is correct?

``````for(int i = 0; i<360; i+=10){
}
``````

OR,

``````for(int i = 0; i<360; i+=10){
}
``````

The second one seems to be correct, but ofRotate is in degrees, right? So is there a handy reference, or a rule of thumb as to what’s should be in degrees and what should be in radians?

PS. Seems like a bunch of code I’ve written in the last few months have this rather basic, stupid error in them

1 Like

As cos and sin are part of the C math library and not OF they don’t follow the rule of degrees by default.
Generally any function beginning with ofSomething or an ofSomething class will use degrees unless its specified as radians.

So in this case your second example is correct.

Hope that helps!
Theo

until now every OF function has been using degrees (cause opengl used degrees too) so your assumption is correct but cos and sin are not really OF functions but standard c++ ones (easy to differentiate because they don’t start with of…) so they are in radians which is the standard for trigonometrical functions

from 0.10 on which is about to be released, OF functions will have an explcit Deg/Rad suffix so ofRotate becomes ofRotateDeg but you also have ofRotateRad.

This has been added cause the new math library we use, glm, also uses radians so having explicit naming makes things less confusing.

So in general until 0.9.8 evenything that starts with of… or gl… or is a method of an of… class is in degrees while everything that is not OF specific is usually in radians

1 Like

Thanks for clearing it up @theo and for the heads up about 0.10 @arturo. Much appreciated

Thanks on this @ayruos @theo & @arturo