Just wondering if there is any more elegant (less variables) way of doing this, maybe without output variable, using “this” or something like that.
Thanks
ofPoint r2xy (float a, float m) {
ofPoint output;
output.x = m * cos(PI*a/180.0);
output.y = m * sin(PI*a/180.0);
return output;
}
ofPoint r2xy (float a, float m) {
return ofPoint ( m * cos(PI*a/180.0), m * sin(PI*a/180.0) );
}
but you syntax is actually clearer and the compiler will optimize it to be the same as this so it’s not really needed if you are worried about performance
but after looking at it for a sec i realized you’re just doing polar to cartesian conversion, and i’m kind of surprised this isn’t in the core. it should be a method of ofVec2f maybe.