I’m currently trying to convert 2 angles into x, y, z, using a formula from Matlab from Mathworks, Sph2Cart
http://www.mathworks.com/help/techdoc/ref/sph2cart.html
Algorithm:
x = r .* cos(elevation) .* cos(azimuth)
y = r .* cos(elevation) .* sin(azimuth)
z = r .* sin(elevation)
In C++
clax = 1 * cos((Altitude/360)*(2*XM_PI)) * cos((Azimuth/360)*(2*XM_PI));
clay = 1 * sin((Altitude/360)*(2*XM_PI));
claz = 1 * cos((Altitude/360)*(2*XM_PI)) * sin((Azimuth/360)*(2*XM_PI));
But no matter what Altitude and Azimuth is, clax, clay and claz is either 0 or 1.
I’m sure that i made a mistake, and i will laugh after this how stupid i was. But really, i have no idea why this doesn’t work, why the values only give 1 or 0 for each of them…
In all likelihood, you declared
claxas some integer type (e.g.int,long, …). Otherwise,AltitudeorAzimuthmight be declared as integer types. In that case you would always wind up with multiples of2*piin the arguments to the trigonometric functions.