Hi,
I've asked on StackOverflow and not had an answer which helps, so I thought it best to ask here. I have a sphere with a texture of the earth. Everything appears correct. If I draw a point on that sphere using latitude and longitude, I have to switch around XYZ in order for the object to appear in the correct location.
I am using the following to translate lat and lon:-
LAT = latitude * pi/180
LON = longitude * pi/180
x = -R * cos(LAT) * cos(LON)
y = R * sin(LAT)
z = R * cos(LAT) * sin(LON)
My method for translating the points is as follows: -
-(SCNVector3) vectorFromCoordinate:(GLfloat)lat lon:(GLfloat)lon distance:(GLfloat)radius
{
SCNVector3 result;
lat = DEGREES_TO_RADIANS(lat);
lon = DEGREES_TO_RADIANS(lon);
result.z = cos(lat) * cos(lon) * radius;
result.x = cos(lat) * sin(lon) * -radius;
result.y = sin(lat) * radius;
return result;
}
As you can see, the formula for X is used to calculate Z, the forumla to calculate Y is used to calcuate X and the formula to calculate Z is used to calculate Y. I haven't done anything out of the ordinary, I've simply created a sphere with a radius and added it to a scene's root node... so my question is, why am I having to use XYZ as ZXY in order to plot at the correct location?