Hello all,
I'm very confused by the values given by cart2sph in zexy 1.1. They conflict with my original expr based equation.
So If I have x=5, y=5 and z=5
cart2sph gives me: r=8.66, phi=0.78, theta=0.61
In my own implementation I get: r=8.66, theta=0.955, phi=0.78
I'm using this equation:
x^2+y^2+z^2=r^2 theta=cos^-1(z/r) phi=tan^-1(y/x)
From the zexy source I see:
x->new_coord[0]=sqrtf(X*X+Y*Y+Z*Z); /* R */ x->new_coord[1]=atan2f(Y, X); /* PHI */ x->new_coord[2]=atan2f(Z, sqrt(X*X+Y*Y)); /* THETA */
Close, but not quite?! sorry my trig is not the best. Can anyone give me a hand with whats going on?
Thanks! Ben
PS: I attached my own expr version for comparison