jamoma / JamomaCore

Jamoma Frameworks for Audio and Control Structure
Other
36 stars 14 forks source link

wrong formulas in polar / spherical dataspaces #399

Closed jcelerier closed 6 years ago

jcelerier commented 6 years ago

e.g.

output[0] = atan2(xx, yy) * kTTRadiansToDegrees; //a
output[1] = pow(((xx * xx) + (yy * yy)), 0.5); //distance

I think that it should be atan2(yy, xx): the "naive math" formula is

x = r cos theta y = r sin theta

=>

r = sqrt(...) theta = arctan(y/x)

and arctan(y/x) ~ atan2(y, x)

lossius commented 6 years ago

I'm sure that if you review the code for this dataspace you'll find oddities several places. The reason is because we are using non-standard mathematical conversions:

This makes the formulas for conversions between Cartesian and Polar different to what you'd expect in a maths class.

jcelerier commented 6 years ago

good to know, thanks! are there other conventions used in the dataspaces documented somewhere ?