/**
|
* Computes a 3x3 rotation matrix that transforms vectors from an ellipsoid's east-north-up coordinate system
|
* to eye coordinates. In east-north-up coordinates, x points east, y points north, and z points along the
|
* surface normal. East-north-up can be used as an ellipsoid's tangent space for operations such as bump mapping.
|
* <br /><br />
|
* The ellipsoid is assumed to be centered at the model coordinate's origin.
|
*
|
* @name czm_eastNorthUpToEyeCoordinates
|
* @glslFunction
|
*
|
* @param {vec3} positionMC The position on the ellipsoid in model coordinates.
|
* @param {vec3} normalEC The normalized ellipsoid surface normal, at <code>positionMC</code>, in eye coordinates.
|
*
|
* @returns {mat3} A 3x3 rotation matrix that transforms vectors from the east-north-up coordinate system to eye coordinates.
|
*
|
* @example
|
* // Transform a vector defined in the east-north-up coordinate
|
* // system, (0, 0, 1) which is the surface normal, to eye
|
* // coordinates.
|
* mat3 m = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);
|
* vec3 normalEC = m * vec3(0.0, 0.0, 1.0);
|
*/
|
mat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)
|
{
|
vec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0)); // normalized surface tangent in model coordinates
|
vec3 tangentEC = normalize(czm_normal3D * tangentMC); // normalized surface tangent in eye coordiantes
|
vec3 bitangentEC = normalize(cross(normalEC, tangentEC)); // normalized surface bitangent in eye coordinates
|
|
return mat3(
|
tangentEC.x, tangentEC.y, tangentEC.z,
|
bitangentEC.x, bitangentEC.y, bitangentEC.z,
|
normalEC.x, normalEC.y, normalEC.z);
|
}
|