I'm working on a representation of the Earth and moving on it.
I use geolocation (latitude+longitude) and the direction in which I'm moving is the angle between, in the tangent plane to the Earth where I am, a North-South axis (remaining away from poles, so) and a vertex representing the forward direction.
I would like to compute an orthonormal coordinate system at the viewer position. The up vertex is easy, I just have to normalize the position (as the center of the Earth is (0,0,0)). Then I would like to have a forward vertex and a left vertex (in the tangent plane, so). What is the easiest way to get them both?
Thanks for your help
Cathy L.
Cathy, do you have any experience with the vector cross-product in 3D? The relevance of the cross-product is that it can find orthogonal directions for you. The local 3D axes you want to superimpose locally on a geolocation requires you to construct 3 axis directions (local east, local north, and local_z (up)). Each of these directions is expressed in a geocentric coordinate system (your reference global coordinates). In these global coordinates (for stationary, non-rotating Earth), the 3D axes are:
• origin - at the geocenter of the Earth
• + x-axis points out to geolocation [ 0, 0 ] (near Nigeria)
• + y-axis points out to geolocation [ +90, 0 ] (in Indian Ocean)
• + z-axis points out North Pole
Getting back to cross-products, they result in a direction mutually perpendicular to the two input vectors. How can this be used to get a local East at [Lon, Lat]?
What if you take the cross-product using the local "up"? (which you brilliantly figured out is just the normalized direction vector equivalent to [Lon, Lat]
d_local_z = [ cos(lat)cos(lon), cos(lat)sin(lon), sin(lat) ]
What direction could you cross it with? How about the global Z direction (Earth center to North Pole) [ 0 0 1] ? Using the right hand rule (do you know this rule?), the resulting vector pointing to local East is [ 0 0 1 ] X d_local_z.
Also, because of the way the cross-product gives a variable length result vector, the result has to be normalized before using it as a direction vector (or as an axis definition).
d_local_east = normalize( [ 0 0 1 ] X d_local_z )
The d_local_north direction can be computed as a cross-product, using what you've got so far for d_local_z and d_local_east. See if you can figure out (using right hand rule) whether you want
d_local_north = normalized ( d_local_east X d_local_z )
or
d_local_north = normalized ( d_local_z X d_local_east )
Now, that you have the 3 local axes as direction vectors, you're very close to being able to convert from global cartesian coordinates --> local cartesian coordinates in a rotated frame at geoloc [ lon, lat ].
And, once you have that conversion, you can represent motions as vectors, and convert these using coordinate rotation.