Optimized GTX_matrix_interpolation axisAngle function

This commit is contained in:
Christophe Riccio 2016-11-20 23:39:22 +01:00
parent 29535189f1
commit b09f395cd2
3 changed files with 13 additions and 11 deletions

View File

@ -14,8 +14,8 @@ namespace glm
rgbColor = tvec3<T, P>(hsv.z); rgbColor = tvec3<T, P>(hsv.z);
else else
{ {
T sector = floor(hsv.x / T(60)); T sector = floor(hsv.x * (T(1) / T(60)));
T frac = (hsv.x / T(60)) - sector; T frac = (hsv.x * (T(1) / T(60))) - sector;
// factorial part of h // factorial part of h
T o = hsv.z * (T(1) - hsv.y); T o = hsv.z * (T(1) - hsv.y);
T p = hsv.z * (T(1) - hsv.y * frac); T p = hsv.z * (T(1) - hsv.y * frac);

View File

@ -25,12 +25,12 @@ namespace glm
return; return;
} }
angle = static_cast<T>(3.1415926535897932384626433832795); angle = static_cast<T>(3.1415926535897932384626433832795);
T xx = (mat[0][0] + (T)1.0) / (T)2.0; T xx = (mat[0][0] + (T)1.0) * (T)0.5;
T yy = (mat[1][1] + (T)1.0) / (T)2.0; T yy = (mat[1][1] + (T)1.0) * (T)0.5;
T zz = (mat[2][2] + (T)1.0) / (T)2.0; T zz = (mat[2][2] + (T)1.0) * (T)0.5;
T xy = (mat[1][0] + mat[0][1]) / (T)4.0; T xy = (mat[1][0] + mat[0][1]) * (T)0.25;
T xz = (mat[2][0] + mat[0][2]) / (T)4.0; T xz = (mat[2][0] + mat[0][2]) * (T)0.25;
T yz = (mat[2][1] + mat[1][2]) / (T)4.0; T yz = (mat[2][1] + mat[1][2]) * (T)0.25;
if((xx > yy) && (xx > zz)) if((xx > yy) && (xx > zz))
{ {
if (xx < epsilon) { if (xx < epsilon) {
@ -72,7 +72,7 @@ namespace glm
T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1])); T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1]));
if (glm::abs(s) < T(0.001)) if (glm::abs(s) < T(0.001))
s = (T)1.0; s = (T)1.0;
angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) / (T)2.0); angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) * (T)0.5);
axis.x = (mat[1][2] - mat[2][1]) / s; axis.x = (mat[1][2] - mat[2][1]) / s;
axis.y = (mat[2][0] - mat[0][2]) / s; axis.y = (mat[2][0] - mat[0][2]) / s;
axis.z = (mat[0][1] - mat[1][0]) / s; axis.z = (mat[0][1] - mat[1][0]) / s;

View File

@ -60,10 +60,12 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
- Added [GLM_ENABLE_EXPERIMENTAL](manual.md#section7_4) to enable experimental features. - Added [GLM_ENABLE_EXPERIMENTAL](manual.md#section7_4) to enable experimental features.
#### Improvements: #### Improvements:
- Added lowp variant of GTC_colorspace convertLinearToSRGB #419 - Added lowp variant of GTC_color_space convertLinearToSRGB #419
- Replaced the manual by a markdown version #458 - Replaced the manual by a markdown version #458
- Optimized GTC_packing implementation - Optimized GTC_packing implementation
- Optimized noise functions - Optimized GTC_noise functions
- Optimized GTC_color_space HSV to RGB conversions
- Optimized GTX_matrix_interpolation axisAngle function
- Added FAQ 12: Windows headers cause build errors... #557 - Added FAQ 12: Windows headers cause build errors... #557
#### Fixes: #### Fixes: