This commit is contained in:
Branimir Karadžić
2018-01-13 17:02:28 -08:00
parent 3c1ac9b021
commit 2c1d20ae06
2 changed files with 11 additions and 6 deletions

View File

@@ -396,13 +396,13 @@ namespace bx
_vec[2] = -st*cp;
}
inline void vec3ToLatLong(float* _u, float* _v, const float* _vec)
inline void vec3ToLatLong(float* _outU, float* _outV, const float* _dir)
{
const float phi = atan2(_vec[0], _vec[2]);
const float theta = acos(_vec[1]);
const float phi = atan2(_dir[0], _dir[2]);
const float theta = acos(_dir[1]);
*_u = (kPi + phi)*kInvPi*0.5f;
*_v = theta*kInvPi;
*_outU = (bx::kPi + phi)/bx::kPi2;
*_outV = theta*bx::kInvPi;
}
inline void quatIdentity(float* _result)

View File

@@ -248,8 +248,13 @@ namespace bx
///
void vec3FromLatLong(float* _vec, float _u, float _v);
/// Convert direction to 2D latitude and longitude.
///
void vec3ToLatLong(float* _u, float* _v, const float* _vec);
/// @param[out] _outU U-coordinate.
/// @param[out] _outV V-coordinate.
/// @param[in] _dir Normalized direction vector.
///
void vec3ToLatLong(float* _outU, float* _outV, const float* _dir)
///
void quatIdentity(float* _result);