I have this sphere implementation:
float x = (float) (cos(phi) * cos(theta));
float y = (float) sin(phi);
float z = (float) (cos(phi) * sin(theta));
taken from a source code.
I read: to calculate sphere tangents i must do the partial derivative of x, y, z (in respec to theta). So i should have:
tx = -cos(phi)*sin(theta)
ty = 0
tz = cos(phi)*cos(theta)
if i’m right. But reading the code, here is the adopted solution:
float tx = (float) (sin(phi) * sin(theta));
float ty = (float) -cos(phi);
float tz = (float) (sin(phi) * cos(theta));
Why?
Thank you for the answers and sorry for my english!