Merge branch '0.9.3' into swizzle

This commit is contained in:
Christophe Riccio 2011-10-14 14:08:15 +01:00
commit e93b6eb518
54 changed files with 5019 additions and 6933 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,16 +10,16 @@
#ifndef glm_gtx_closest_point #ifndef glm_gtx_closest_point
#define glm_gtx_closest_point #define glm_gtx_closest_point
namespace glm{ namespace glm
{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
( (
detail::tvec3<valType> const & point, detail::tvec3<valType> const & point,
detail::tvec3<valType> const & a, detail::tvec3<valType> const & a,
detail::tvec3<valType> const & b detail::tvec3<valType> const & b
) )
{ {
valType LineLength = distance(a, b); valType LineLength = distance(a, b);
detail::tvec3<valType> Vector = point - a; detail::tvec3<valType> Vector = point - a;
detail::tvec3<valType> LineDirection = (b - a) / LineLength; detail::tvec3<valType> LineDirection = (b - a) / LineLength;
@ -30,8 +30,7 @@ GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
if(Distance <= valType(0)) return a; if(Distance <= valType(0)) return a;
if(Distance >= LineLength) return b; if(Distance >= LineLength) return b;
return a + LineDirection * Distance; return a + LineDirection * Distance;
} }
}//namespace glm }//namespace glm
#endif//glm_gtx_closest_point #endif//glm_gtx_closest_point

File diff suppressed because it is too large Load Diff

View File

@ -7,11 +7,11 @@
// File : glm/gtx/color_space.inl // File : glm/gtx/color_space.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
{ {
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
{
detail::tvec3<T> hsv = hsvColor; detail::tvec3<T> hsv = hsvColor;
detail::tvec3<T> rgbColor; detail::tvec3<T> rgbColor;
@ -64,11 +64,11 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
} }
return rgbColor; return rgbColor;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> hsvColor(const detail::tvec3<T>& rgbColor) GLM_FUNC_QUALIFIER detail::tvec3<T> hsvColor(const detail::tvec3<T>& rgbColor)
{ {
detail::tvec3<T> hsv = rgbColor; detail::tvec3<T> hsv = rgbColor;
float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b); float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b);
float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b); float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b);
@ -104,11 +104,11 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> hsvColor(const detail::tvec3<T>& rgbColor)
} }
return hsv; return hsv;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s) GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s)
{ {
detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722)); detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722));
T col0 = (T(1) - s) * rgbw.r; T col0 = (T(1) - s) * rgbw.r;
@ -126,25 +126,24 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s)
result[2][1] = col2; result[2][1] = col2;
result[2][2] = col2 + s; result[2][2] = col2 + s;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> saturation(const T s, const detail::tvec3<T>& color) GLM_FUNC_QUALIFIER detail::tvec3<T> saturation(const T s, const detail::tvec3<T>& color)
{ {
return detail::tvec3<T>(saturation(s) * detail::tvec4<T>(color, T(0))); return detail::tvec3<T>(saturation(s) * detail::tvec4<T>(color, T(0)));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> saturation(const T s, const detail::tvec4<T>& color) GLM_FUNC_QUALIFIER detail::tvec4<T> saturation(const T s, const detail::tvec4<T>& color)
{ {
return saturation(s) * color; return saturation(s) * color;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3<T>& color) GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3<T>& color)
{ {
const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11); const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11);
return dot(color, tmp); return dot(color, tmp);
} }
}//namespace glm }//namespace glm

View File

@ -7,59 +7,58 @@
// File : glm/gtx/color_space_YCoCg.inl // File : glm/gtx/color_space_YCoCg.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg
(
detail::tvec3<valType> const & rgbColor
)
{ {
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg
(
detail::tvec3<valType> const & rgbColor
)
{
detail::tvec3<valType> result; detail::tvec3<valType> result;
result.x/*Y */ = rgbColor.r / valType(4) + rgbColor.g / valType(2) + rgbColor.b / valType(4); result.x/*Y */ = rgbColor.r / valType(4) + rgbColor.g / valType(2) + rgbColor.b / valType(4);
result.y/*Co*/ = rgbColor.r / valType(2) + rgbColor.g * valType(0) - rgbColor.b / valType(2); result.y/*Co*/ = rgbColor.r / valType(2) + rgbColor.g * valType(0) - rgbColor.b / valType(2);
result.z/*Cg*/ = - rgbColor.r / valType(4) + rgbColor.g / valType(2) - rgbColor.b / valType(4); result.z/*Cg*/ = - rgbColor.r / valType(4) + rgbColor.g / valType(2) - rgbColor.b / valType(4);
return result; return result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCgR GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCgR
( (
detail::tvec3<valType> const & rgbColor detail::tvec3<valType> const & rgbColor
) )
{ {
detail::tvec3<valType> result; detail::tvec3<valType> result;
result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4); result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4);
result.y/*Co*/ = rgbColor.r - rgbColor.b; result.y/*Co*/ = rgbColor.r - rgbColor.b;
result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2); result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2);
return result; return result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCg2rgb GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCg2rgb
( (
detail::tvec3<valType> const & YCoCgColor detail::tvec3<valType> const & YCoCgColor
) )
{ {
detail::tvec3<valType> result; detail::tvec3<valType> result;
result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z; result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z;
result.g = YCoCgColor.x + YCoCgColor.z; result.g = YCoCgColor.x + YCoCgColor.z;
result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z; result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z;
return result; return result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCgR2rgb GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCgR2rgb
( (
detail::tvec3<valType> const & YCoCgRColor detail::tvec3<valType> const & YCoCgRColor
) )
{ {
detail::tvec3<valType> result; detail::tvec3<valType> result;
valType tmp = YCoCgRColor.x - (YCoCgRColor.z / valType(2)); valType tmp = YCoCgRColor.x - (YCoCgRColor.z / valType(2));
result.g = YCoCgRColor.z + tmp; result.g = YCoCgRColor.z + tmp;
result.b = tmp - (YCoCgRColor.y / valType(2)); result.b = tmp - (YCoCgRColor.y / valType(2));
result.r = result.b + YCoCgRColor.y; result.r = result.b + YCoCgRColor.y;
return result; return result;
} }
}//namespace glm }//namespace glm

View File

@ -7,131 +7,130 @@
// File : glm/gtx/compatibility.inl // File : glm/gtx/compatibility.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
// isfinite // isfinite
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool isfinite( GLM_FUNC_QUALIFIER bool isfinite(
genType const & x) genType const & x)
{ {
#if(GLM_COMPILER & GLM_COMPILER_VC) #if(GLM_COMPILER & GLM_COMPILER_VC)
return _finite(x); return _finite(x);
#else//(GLM_COMPILER & GLM_COMPILER_GCC) #else//(GLM_COMPILER & GLM_COMPILER_GCC)
return std::isfinite(x) != 0; return std::isfinite(x) != 0;
#endif #endif
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> isfinite( GLM_FUNC_QUALIFIER detail::tvec2<bool> isfinite(
detail::tvec2<valType> const & x) detail::tvec2<valType> const & x)
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
isfinite(x.x), isfinite(x.x),
isfinite(x.y)); isfinite(x.y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> isfinite( GLM_FUNC_QUALIFIER detail::tvec3<bool> isfinite(
detail::tvec3<valType> const & x) detail::tvec3<valType> const & x)
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
isfinite(x.x), isfinite(x.x),
isfinite(x.y), isfinite(x.y),
isfinite(x.z)); isfinite(x.z));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> isfinite( GLM_FUNC_QUALIFIER detail::tvec4<bool> isfinite(
detail::tvec4<valType> const & x) detail::tvec4<valType> const & x)
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
isfinite(x.x), isfinite(x.x),
isfinite(x.y), isfinite(x.y),
isfinite(x.z), isfinite(x.z),
isfinite(x.w)); isfinite(x.w));
} }
// isinf // isinf
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool isinf( GLM_FUNC_QUALIFIER bool isinf(
genType const & x) genType const & x)
{ {
#if(GLM_COMPILER & GLM_COMPILER_VC) #if(GLM_COMPILER & GLM_COMPILER_VC)
return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF;
#else #else
return std::isinf(x) != 0; return std::isinf(x) != 0;
#endif #endif
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> isinf( GLM_FUNC_QUALIFIER detail::tvec2<bool> isinf(
detail::tvec2<valType> const & x) detail::tvec2<valType> const & x)
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
isinf(x.x), isinf(x.x),
isinf(x.y)); isinf(x.y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> isinf( GLM_FUNC_QUALIFIER detail::tvec3<bool> isinf(
detail::tvec3<valType> const & x) detail::tvec3<valType> const & x)
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
isinf(x.x), isinf(x.x),
isinf(x.y), isinf(x.y),
isinf(x.z)); isinf(x.z));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> isinf( GLM_FUNC_QUALIFIER detail::tvec4<bool> isinf(
detail::tvec4<valType> const & x) detail::tvec4<valType> const & x)
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
isinf(x.x), isinf(x.x),
isinf(x.y), isinf(x.y),
isinf(x.z), isinf(x.z),
isinf(x.w)); isinf(x.w));
} }
// isnan // isnan
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool isnan(genType const & x) GLM_FUNC_QUALIFIER bool isnan(genType const & x)
{ {
#if(GLM_COMPILER & GLM_COMPILER_VC) #if(GLM_COMPILER & GLM_COMPILER_VC)
return _isnan(x); return _isnan(x);
#else #else
return std::isnan(x) != 0; return std::isnan(x) != 0;
#endif #endif
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> isnan( GLM_FUNC_QUALIFIER detail::tvec2<bool> isnan(
detail::tvec2<valType> const & x) detail::tvec2<valType> const & x)
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
isnan(x.x), isnan(x.x),
isnan(x.y)); isnan(x.y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> isnan( GLM_FUNC_QUALIFIER detail::tvec3<bool> isnan(
detail::tvec3<valType> const & x) detail::tvec3<valType> const & x)
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
isnan(x.x), isnan(x.x),
isnan(x.y), isnan(x.y),
isnan(x.z)); isnan(x.z));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> isnan( GLM_FUNC_QUALIFIER detail::tvec4<bool> isnan(
detail::tvec4<valType> const & x) detail::tvec4<valType> const & x)
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
isnan(x.x), isnan(x.x),
isnan(x.y), isnan(x.y),
isnan(x.z), isnan(x.z),
isnan(x.w)); isnan(x.w));
} }
}//namespace glm }//namespace glm

View File

@ -7,42 +7,41 @@
// File : gtx_component_wise.inl // File : gtx_component_wise.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
{ {
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
{
typename genType::size_type result = typename genType::value_type(0); typename genType::size_type result = typename genType::value_type(0);
for(typename genType::size_type i = 0; i < genType::value_size(); ++i) for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
result += v[i]; result += v[i];
return result; return result;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v) GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v)
{ {
typename genType::value_type result = typename genType::value_type(1); typename genType::value_type result = typename genType::value_type(1);
for(typename genType::size_type i = 0; i < genType::value_size(); ++i) for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
result *= v[i]; result *= v[i];
return result; return result;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v) GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v)
{ {
typename genType::value_type result = typename genType::value_type(v[0]); typename genType::value_type result = typename genType::value_type(v[0]);
for(typename genType::size_type i = 1; i < genType::value_size(); ++i) for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
result = min(result, v[i]); result = min(result, v[i]);
return result; return result;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v) GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v)
{ {
typename genType::value_type result = typename genType::value_type(v[0]); typename genType::value_type result = typename genType::value_type(v[0]);
for(typename genType::size_type i = 1; i < genType::value_size(); ++i) for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
result = max(result, v[i]); result = max(result, v[i]);
return result; return result;
} }
}//namespace glm }//namespace glm

View File

@ -20,773 +20,8 @@
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE. /// THE SOFTWARE.
/// ///
/// @ref gtc_half_float /// @ref gtx_constants
/// @file glm/gtc/half_float.inl /// @file glm/gtx/constants.inl
/// @date 2009-04-29 / 2011-06-05 /// @date 2011-10-14 / 2011-10-14
/// @author Christophe Riccio /// @author Christophe Riccio
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "../core/_detail.hpp"
namespace glm{
template <typename genIType>
GLM_FUNC_QUALIFIER genIType mask
(
genIType const & count
)
{
return ((genIType(1) << (count)) - genIType(1));
}
template <typename valIType>
GLM_FUNC_QUALIFIER detail::tvec2<valIType> mask
(
detail::tvec2<valIType> const & count
)
{
return detail::tvec2<valIType>(
mask(count[0]),
mask(count[1]));
}
template <typename valIType>
GLM_FUNC_QUALIFIER detail::tvec3<valIType> mask
(
detail::tvec3<valIType> const & count
)
{
return detail::tvec3<valIType>(
mask(count[0]),
mask(count[1]),
mask(count[2]));
}
template <typename valIType>
GLM_FUNC_QUALIFIER detail::tvec4<valIType> mask
(
detail::tvec4<valIType> const & count
)
{
return detail::tvec4<valIType>(
mask(count[0]),
mask(count[1]),
mask(count[2]),
mask(count[3]));
}
// extractField
template <typename genIType>
GLM_FUNC_QUALIFIER genIType extractField
(
half const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(half));
return (value._data() << first) >> ((sizeof(half) << 3) - count);
}
template <typename genIType>
GLM_FUNC_QUALIFIER genIType extractField
(
float const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(float));
return (detail::uif32(value).i << first) >> ((sizeof(float) << 3) - count);
}
template <typename genIType>
GLM_FUNC_QUALIFIER genIType extractField
(
double const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(double));
return (detail::uif64(value).i << first) >> ((sizeof(double) << genIType(3)) - count);
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER genIUType extractField
(
genIUType const & Value,
sizeType const & First,
sizeType const & Count
)
{
sizeType GenSize = sizeof(genIUType) << 3;
assert(First + Count <= GenSize);
genIUType ShiftLeft = Count ? Value << (GenSize - (Count + First)) : 0;
genIUType ShiftBack = ShiftLeft >> genIUType(GenSize - Count);
return ShiftBack;
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
(
detail::tvec2<genIUType> const & value,
sizeType const & first,
sizeType const & count
)
{
return detail::tvec2<genIUType>(
extractField(value[0], first, count),
extractField(value[1], first, count));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
(
detail::tvec3<genIUType> const & value,
sizeType const & first,
sizeType const & count
)
{
return detail::tvec3<genIUType>(
extractField(value[0], first, count),
extractField(value[1], first, count),
extractField(value[2], first, count));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
(
detail::tvec4<genIUType> const & value,
sizeType const & first,
sizeType const & count
)
{
return detail::tvec4<genIUType>(
extractField(value[0], first, count),
extractField(value[1], first, count),
extractField(value[2], first, count),
extractField(value[3], first, count));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
(
detail::tvec2<genIUType> const & value,
detail::tvec2<sizeType> const & first,
detail::tvec2<sizeType> const & count
)
{
return detail::tvec2<genIUType>(
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
(
detail::tvec3<genIUType> const & value,
detail::tvec3<sizeType> const & first,
detail::tvec3<sizeType> const & count
)
{
return detail::tvec3<genIUType>(
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]),
extractField(value[2], first[2], count[2]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
(
detail::tvec4<genIUType> const & value,
detail::tvec4<sizeType> const & first,
detail::tvec4<sizeType> const & count
)
{
return detail::tvec4<genIUType>(
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]),
extractField(value[2], first[2], count[2]),
extractField(value[3], first[3], count[3]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
(
genIUType const & value,
detail::tvec2<sizeType> const & first,
detail::tvec2<sizeType> const & count
)
{
return detail::tvec2<genIUType>(
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
(
genIUType const & value,
detail::tvec3<sizeType> const & first,
detail::tvec3<sizeType> const & count
)
{
return detail::tvec3<genIUType>(
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]),
extractField(value, first[2], count[2]));
}
template <typename genIUType, typename sizeType>
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
(
genIUType const & value,
detail::tvec4<sizeType> const & first,
detail::tvec4<sizeType> const & count
)
{
return detail::tvec4<genIUType>(
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]),
extractField(value, first[2], count[2]),
extractField(value, first[3], count[3]));
}
// lowestBit
template <typename genType>
GLM_FUNC_QUALIFIER int lowestBit
(
genType const & Value
)
{
assert(Value != genType(0)); // not valid call
genType Bit;
for(Bit = genType(0); !(Value & (1 << Bit)); ++Bit){}
return Bit;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<int> lowestBit
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
lowestBit(value[0]),
lowestBit(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<int> lowestBit
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
lowestBit(value[0]),
lowestBit(value[1]),
lowestBit(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<int> lowestBit
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
lowestBit(value[0]),
lowestBit(value[1]),
lowestBit(value[2]),
lowestBit(value[3]));
}
// highestBit
template <typename genType>
GLM_FUNC_QUALIFIER int highestBit
(
genType const & value
)
{
assert(value != genType(0)); // not valid call
genType bit = genType(-1);
for(genType tmp = value; tmp; tmp >>= 1, ++bit){}
return bit;
}
//template <>
//GLM_FUNC_QUALIFIER int highestBit<int>
//(
// int value
//)
//{
// int bit = -1;
// for(int tmp = value; tmp; tmp >>= 1, ++bit);
// return bit;
//}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<int> highestBit
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
highestBit(value[0]),
highestBit(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<int> highestBit
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
highestBit(value[0]),
highestBit(value[1]),
highestBit(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<int> highestBit
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
highestBit(value[0]),
highestBit(value[1]),
highestBit(value[2]),
highestBit(value[3]));
}
// highestBitValue
template <typename genType>
GLM_FUNC_QUALIFIER genType highestBitValue
(
genType const & value
)
{
genType tmp = value;
genType result = genType(0);
while(tmp)
{
result = (tmp & (~tmp + 1)); // grab lowest bit
tmp &= ~result; // clear lowest bit
}
return result;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<int> highestBitValue
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
highestBitValue(value[0]),
highestBitValue(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<int> highestBitValue
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
highestBitValue(value[0]),
highestBitValue(value[1]),
highestBitValue(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<int> highestBitValue
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
highestBitValue(value[0]),
highestBitValue(value[1]),
highestBitValue(value[2]),
highestBitValue(value[3]));
}
// isPowerOfTwo
template <typename genType>
GLM_FUNC_QUALIFIER bool isPowerOfTwo(genType const & Value)
{
//detail::If<std::numeric_limits<genType>::is_signed>::apply(abs, Value);
//return !(Value & (Value - 1));
// For old complier?
genType Result = Value;
if(std::numeric_limits<genType>::is_signed)
Result = abs(Result);
return !(Result & (Result - 1));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> isPowerOfTwo
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> isPowerOfTwo
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]),
isPowerOfTwo(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> isPowerOfTwo
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]),
isPowerOfTwo(value[2]),
isPowerOfTwo(value[3]));
}
// powerOfTwoAbove
template <typename genType>
GLM_FUNC_QUALIFIER genType powerOfTwoAbove(genType const & value)
{
return isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoAbove
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoAbove
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]),
powerOfTwoAbove(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoAbove
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]),
powerOfTwoAbove(value[2]),
powerOfTwoAbove(value[3]));
}
// powerOfTwoBelow
template <typename genType>
GLM_FUNC_QUALIFIER genType powerOfTwoBelow
(
genType const & value
)
{
return isPowerOfTwo(value) ? value : highestBitValue(value);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoBelow
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoBelow
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]),
powerOfTwoBelow(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoBelow
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]),
powerOfTwoBelow(value[2]),
powerOfTwoBelow(value[3]));
}
// powerOfTwoNearest
template <typename genType>
GLM_FUNC_QUALIFIER genType powerOfTwoNearest
(
genType const & value
)
{
if(isPowerOfTwo(value))
return value;
genType prev = highestBitValue(value);
genType next = prev << 1;
return (next - value) < (value - prev) ? next : prev;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoNearest
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoNearest
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]),
powerOfTwoNearest(value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoNearest
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]),
powerOfTwoNearest(value[2]),
powerOfTwoNearest(value[3]));
}
template <typename genType>
GLM_FUNC_QUALIFIER genType bitRevert(genType const & In)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRevert' only accept integer values");
genType Out = 0;
std::size_t BitSize = sizeof(genType) * 8;
for(std::size_t i = 0; i < BitSize; ++i)
if(In & (genType(1) << i))
Out |= genType(1) << (BitSize - 1 - i);
return Out;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRevert
(
detail::tvec2<valType> const & Value
)
{
return detail::tvec2<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRevert
(
detail::tvec3<valType> const & Value
)
{
return detail::tvec3<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]),
bitRevert(Value[2]));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRevert
(
detail::tvec4<valType> const & Value
)
{
return detail::tvec4<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]),
bitRevert(Value[2]),
bitRevert(Value[3]));
}
template <typename genType>
GLM_FUNC_QUALIFIER genType bitRotateRight(genType const & In, std::size_t Shift)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateRight' only accept integer values");
std::size_t BitSize = sizeof(genType) * 8;
return (In << Shift) | (In >> (BitSize - Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateRight
(
detail::tvec2<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec2<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateRight
(
detail::tvec3<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec3<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift),
bitRotateRight(Value[2], Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateRight
(
detail::tvec4<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec4<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift),
bitRotateRight(Value[2], Shift),
bitRotateRight(Value[3], Shift));
}
template <typename genType>
GLM_FUNC_QUALIFIER genType bitRotateLeft(genType const & In, std::size_t Shift)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateLeft' only accept integer values");
std::size_t BitSize = sizeof(genType) * 8;
return (In >> Shift) | (In << (BitSize - Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateLeft
(
detail::tvec2<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec2<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateLeft
(
detail::tvec3<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec3<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift),
bitRotateLeft(Value[2], Shift));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateLeft
(
detail::tvec4<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec4<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift),
bitRotateLeft(Value[2], Shift),
bitRotateLeft(Value[3], Shift));
}
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType fillBitfieldWithOne
(
genIUType const & Value,
int const & FromBit,
int const & ToBit
)
{
assert(FromBit <= ToBit);
assert(ToBit <= sizeof(genIUType) * std::size_t(8));
genIUType Result = Value;
for(std::size_t i = 0; i <= ToBit; ++i)
Result |= (1 << i);
return Result;
}
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType fillBitfieldWithZero
(
genIUType const & Value,
int const & FromBit,
int const & ToBit
)
{
assert(FromBit <= ToBit);
assert(ToBit <= sizeof(genIUType) * std::size_t(8));
genIUType Result = Value;
for(std::size_t i = 0; i <= ToBit; ++i)
Result &= ~(1 << i);
return Result;
}
}//namespace glm

View File

@ -7,224 +7,223 @@
// File : glm/gtx/epsilon.inl // File : glm/gtx/epsilon.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool equalEpsilon GLM_FUNC_QUALIFIER bool equalEpsilon
( (
genType const & x, genType const & x,
genType const & y, genType const & y,
genType const & epsilon genType const & epsilon
) )
{ {
return abs(x - y) < epsilon; return abs(x - y) < epsilon;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool notEqualEpsilon GLM_FUNC_QUALIFIER bool notEqualEpsilon
( (
genType const & x, genType const & x,
genType const & y, genType const & y,
genType const & epsilon genType const & epsilon
) )
{ {
return abs(x - y) >= epsilon; return abs(x - y) >= epsilon;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
( (
detail::tvec2<valType> const & x, detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y, detail::tvec2<valType> const & y,
valType const & epsilon) valType const & epsilon)
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
abs(x.x - y.x) < epsilon, abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon); abs(x.y - y.y) < epsilon);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
( (
detail::tvec3<valType> const & x, detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y, detail::tvec3<valType> const & y,
valType const & epsilon) valType const & epsilon)
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
abs(x.x - y.x) < epsilon, abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon, abs(x.y - y.y) < epsilon,
abs(x.z - y.z) < epsilon); abs(x.z - y.z) < epsilon);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
( (
detail::tvec4<valType> const & x, detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y, detail::tvec4<valType> const & y,
valType const & epsilon valType const & epsilon
) )
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon, abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon, abs(x.y - y.y) < epsilon,
abs(x.z - y.z) < epsilon, abs(x.z - y.z) < epsilon,
abs(x.w - y.w) < epsilon); abs(x.w - y.w) < epsilon);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
( (
detail::tvec2<valType> const & x, detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y, detail::tvec2<valType> const & y,
valType const & epsilon valType const & epsilon
) )
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
abs(x.x - y.x) >= epsilon, abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon); abs(x.y - y.y) >= epsilon);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
( (
detail::tvec3<valType> const & x, detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y, detail::tvec3<valType> const & y,
valType const & epsilon valType const & epsilon
) )
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
abs(x.x - y.x) >= epsilon, abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon, abs(x.y - y.y) >= epsilon,
abs(x.z - y.z) >= epsilon); abs(x.z - y.z) >= epsilon);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
( (
detail::tvec4<valType> const & x, detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y, detail::tvec4<valType> const & y,
valType const & epsilon valType const & epsilon
) )
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon, abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon, abs(x.y - y.y) >= epsilon,
abs(x.z - y.z) >= epsilon, abs(x.z - y.z) >= epsilon,
abs(x.w - y.w) >= epsilon); abs(x.w - y.w) >= epsilon);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
( (
detail::tvec2<valType> const & x, detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y, detail::tvec2<valType> const & y,
detail::tvec2<valType> const & epsilon detail::tvec2<valType> const & epsilon
) )
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
abs(x.x - y.x) < epsilon.x, abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y); abs(x.y - y.y) < epsilon.y);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
( (
detail::tvec3<valType> const & x, detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y, detail::tvec3<valType> const & y,
detail::tvec3<valType> const & epsilon detail::tvec3<valType> const & epsilon
) )
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
abs(x.x - y.x) < epsilon.x, abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y, abs(x.y - y.y) < epsilon.y,
abs(x.z - y.z) < epsilon.z); abs(x.z - y.z) < epsilon.z);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
( (
detail::tvec4<valType> const & x, detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y, detail::tvec4<valType> const & y,
detail::tvec4<valType> const & epsilon detail::tvec4<valType> const & epsilon
) )
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon.x, abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y, abs(x.y - y.y) < epsilon.y,
abs(x.z - y.z) < epsilon.z, abs(x.z - y.z) < epsilon.z,
abs(x.w - y.w) < epsilon.w); abs(x.w - y.w) < epsilon.w);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
( (
detail::tquat<valType> const & x, detail::tquat<valType> const & x,
detail::tquat<valType> const & y, detail::tquat<valType> const & y,
detail::tquat<valType> const & epsilon detail::tquat<valType> const & epsilon
) )
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon.x, abs(x.x - y.x) < epsilon.x,
abs(x.y - y.y) < epsilon.y, abs(x.y - y.y) < epsilon.y,
abs(x.z - y.z) < epsilon.z, abs(x.z - y.z) < epsilon.z,
abs(x.w - y.w) < epsilon.w); abs(x.w - y.w) < epsilon.w);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
( (
detail::tvec2<valType> const & x, detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y, detail::tvec2<valType> const & y,
detail::tvec2<valType> const & epsilon detail::tvec2<valType> const & epsilon
) )
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
abs(x.x - y.x) >= epsilon.x, abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y); abs(x.y - y.y) >= epsilon.y);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
( (
detail::tvec3<valType> const & x, detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y, detail::tvec3<valType> const & y,
detail::tvec3<valType> const & epsilon detail::tvec3<valType> const & epsilon
) )
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
abs(x.x - y.x) >= epsilon.x, abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y, abs(x.y - y.y) >= epsilon.y,
abs(x.z - y.z) >= epsilon.z); abs(x.z - y.z) >= epsilon.z);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
( (
detail::tvec4<valType> const & x, detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y, detail::tvec4<valType> const & y,
detail::tvec4<valType> const & epsilon detail::tvec4<valType> const & epsilon
) )
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon.x, abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y, abs(x.y - y.y) >= epsilon.y,
abs(x.z - y.z) >= epsilon.z, abs(x.z - y.z) >= epsilon.z,
abs(x.w - y.w) >= epsilon.w); abs(x.w - y.w) >= epsilon.w);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
( (
detail::tquat<valType> const & x, detail::tquat<valType> const & x,
detail::tquat<valType> const & y, detail::tquat<valType> const & y,
detail::tquat<valType> const & epsilon detail::tquat<valType> const & epsilon
) )
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon.x, abs(x.x - y.x) >= epsilon.x,
abs(x.y - y.y) >= epsilon.y, abs(x.y - y.y) >= epsilon.y,
abs(x.z - y.z) >= epsilon.z, abs(x.z - y.z) >= epsilon.z,
abs(x.w - y.w) >= epsilon.w); abs(x.w - y.w) >= epsilon.w);
} }
}//namespace glm }//namespace glm

View File

@ -7,14 +7,14 @@
// File : glm/gtx/euler_angles.inl // File : glm/gtx/euler_angles.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
(
valType const & angleX
)
{ {
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
(
valType const & angleX
)
{
valType cosX = glm::cos(angleX); valType cosX = glm::cos(angleX);
valType sinX = glm::sin(angleX); valType sinX = glm::sin(angleX);
@ -23,14 +23,14 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
valType(0), cosX, sinX, valType(0), valType(0), cosX, sinX, valType(0),
valType(0),-sinX, cosX, valType(0), valType(0),-sinX, cosX, valType(0),
valType(0), valType(0), valType(0), valType(1)); valType(0), valType(0), valType(0), valType(1));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY
( (
valType const & angleY valType const & angleY
) )
{ {
valType cosY = glm::cos(angleY); valType cosY = glm::cos(angleY);
valType sinY = glm::sin(angleY); valType sinY = glm::sin(angleY);
@ -39,14 +39,14 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY
valType(0), valType(1), valType(0), valType(0), valType(0), valType(1), valType(0), valType(0),
-sinY, valType(0), cosY, valType(0), -sinY, valType(0), cosY, valType(0),
valType(0), valType(0), valType(0), valType(1)); valType(0), valType(0), valType(0), valType(1));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ
( (
valType const & angleZ valType const & angleZ
) )
{ {
valType cosZ = glm::cos(angleZ); valType cosZ = glm::cos(angleZ);
valType sinZ = glm::sin(angleZ); valType sinZ = glm::sin(angleZ);
@ -55,15 +55,15 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ
-sinZ, cosZ, valType(0), valType(0), -sinZ, cosZ, valType(0), valType(0),
valType(0), valType(0), valType(1), valType(0), valType(0), valType(0), valType(1), valType(0),
valType(0), valType(0), valType(0), valType(1)); valType(0), valType(0), valType(0), valType(1));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY
( (
valType const & angleX, valType const & angleX,
valType const & angleY valType const & angleY
) )
{ {
valType cosX = glm::cos(angleX); valType cosX = glm::cos(angleX);
valType sinX = glm::sin(angleX); valType sinX = glm::sin(angleX);
valType cosY = glm::cos(angleY); valType cosY = glm::cos(angleY);
@ -74,15 +74,15 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY
valType(0), cosX, sinX, valType(0), valType(0), cosX, sinX, valType(0),
-sinY , -sinX * cosY, cosX * cosY, valType(0), -sinY , -sinX * cosY, cosX * cosY, valType(0),
valType(0), valType(0), valType(0), valType(1)); valType(0), valType(0), valType(0), valType(1));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX
( (
valType const & angleY, valType const & angleY,
valType const & angleX valType const & angleX
) )
{ {
valType cosX = glm::cos(angleX); valType cosX = glm::cos(angleX);
valType sinX = glm::sin(angleX); valType sinX = glm::sin(angleX);
valType cosY = glm::cos(angleY); valType cosY = glm::cos(angleY);
@ -93,36 +93,36 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX
-sinX * sinY, cosX, sinX * cosY, valType(0), -sinX * sinY, cosX, sinX * cosY, valType(0),
-cosX * sinY, -sinX, cosX * cosY, valType(0), -cosX * sinY, -sinX, cosX * cosY, valType(0),
valType(0), valType(0), valType(0), valType(1)); valType(0), valType(0), valType(0), valType(1));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ
( (
valType const & angleX, valType const & angleX,
valType const & angleZ valType const & angleZ
) )
{ {
return eulerAngleX(angleX) * eulerAngleZ(angleZ); return eulerAngleX(angleX) * eulerAngleZ(angleZ);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX
( (
valType const & angleZ, valType const & angleZ,
valType const & angleX valType const & angleX
) )
{ {
return eulerAngleZ(angleZ) * eulerAngleX(angleX); return eulerAngleZ(angleZ) * eulerAngleX(angleX);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ
( (
valType const & yaw, valType const & yaw,
valType const & pitch, valType const & pitch,
valType const & roll valType const & roll
) )
{ {
valType tmp_ch = glm::cos(yaw); valType tmp_ch = glm::cos(yaw);
valType tmp_sh = glm::sin(yaw); valType tmp_sh = glm::sin(yaw);
valType tmp_cp = glm::cos(pitch); valType tmp_cp = glm::cos(pitch);
@ -148,16 +148,16 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ
Result[3][2] = valType(0); Result[3][2] = valType(0);
Result[3][3] = valType(1); Result[3][3] = valType(1);
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll
( (
valType const & yaw, valType const & yaw,
valType const & pitch, valType const & pitch,
valType const & roll valType const & roll
) )
{ {
valType tmp_ch = glm::cos(yaw); valType tmp_ch = glm::cos(yaw);
valType tmp_sh = glm::sin(yaw); valType tmp_sh = glm::sin(yaw);
valType tmp_cp = glm::cos(pitch); valType tmp_cp = glm::cos(pitch);
@ -183,14 +183,14 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll
Result[3][2] = valType(0); Result[3][2] = valType(0);
Result[3][3] = valType(1); Result[3][3] = valType(1);
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2 GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2
( (
valType const & angle valType const & angle
) )
{ {
valType c = glm::cos(angle); valType c = glm::cos(angle);
valType s = glm::sin(angle); valType s = glm::sin(angle);
@ -200,14 +200,14 @@ GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2
Result[1][0] = -s; Result[1][0] = -s;
Result[1][1] = c; Result[1][1] = c;
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3 GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
( (
valType const & angle valType const & angle
) )
{ {
valType c = glm::cos(angle); valType c = glm::cos(angle);
valType s = glm::sin(angle); valType s = glm::sin(angle);
@ -222,24 +222,23 @@ GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
Result[2][1] = 0.0f; Result[2][1] = 0.0f;
Result[2][2] = 1.0f; Result[2][2] = 1.0f;
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3 GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
( (
detail::tvec3<valType> const & angles detail::tvec3<valType> const & angles
) )
{ {
return detail::tmat3x3<valType>(yawPitchRoll(angles.x, angles.y, angles.z)); return detail::tmat3x3<valType>(yawPitchRoll(angles.x, angles.y, angles.z));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4 GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4
( (
detail::tvec3<valType> const & angles detail::tvec3<valType> const & angles
) )
{ {
return yawPitchRoll(angles.z, angles.x, angles.y); return yawPitchRoll(angles.z, angles.x, angles.y);
} }
}//namespace glm }//namespace glm

View File

@ -7,50 +7,49 @@
// File : glm/gtx/extend.inl // File : glm/gtx/extend.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename genType> template <typename genType>
genType extend genType extend
( (
genType const & Origin, genType const & Origin,
genType const & Source, genType const & Source,
genType const & Distance genType const & Distance
) )
{ {
return Origin + (Source - Origin) * Distance; return Origin + (Source - Origin) * Distance;
} }
template <typename valType> template <typename valType>
detail::tvec2<valType> extend detail::tvec2<valType> extend
( (
detail::tvec2<valType> const & Origin, detail::tvec2<valType> const & Origin,
detail::tvec2<valType> const & Source, detail::tvec2<valType> const & Source,
valType const & Distance valType const & Distance
) )
{ {
return Origin + (Source - Origin) * Distance; return Origin + (Source - Origin) * Distance;
} }
template <typename valType> template <typename valType>
detail::tvec3<valType> extend detail::tvec3<valType> extend
( (
detail::tvec3<valType> const & Origin, detail::tvec3<valType> const & Origin,
detail::tvec3<valType> const & Source, detail::tvec3<valType> const & Source,
valType const & Distance valType const & Distance
) )
{ {
return Origin + (Source - Origin) * Distance; return Origin + (Source - Origin) * Distance;
} }
template <typename valType> template <typename valType>
detail::tvec4<valType> extend detail::tvec4<valType> extend
( (
detail::tvec4<valType> const & Origin, detail::tvec4<valType> const & Origin,
detail::tvec4<valType> const & Source, detail::tvec4<valType> const & Source,
valType const & Distance valType const & Distance
) )
{ {
return Origin + (Source - Origin) * Distance; return Origin + (Source - Origin) * Distance;
} }
}//namespace glm }//namespace glm

View File

@ -54,17 +54,17 @@ namespace glm
//! Faster than the common pow function but less accurate. //! Faster than the common pow function but less accurate.
//! From GLM_GTX_fast_exponential extension. //! From GLM_GTX_fast_exponential extension.
template <typename valType> template <typename genType>
valType fastPow( genType fastPow(
valType const & x, genType const & x,
valType const & y); genType const & y);
//! Faster than the common pow function but less accurate. //! Faster than the common pow function but less accurate.
//! From GLM_GTX_fast_exponential extension. //! From GLM_GTX_fast_exponential extension.
template <typename T, typename U> template <typename genTypeT, typename genTypeU>
T fastPow( genType fastPow(
const T& x, genTypeT const & x,
const U& y); genTypeU const & y);
//! Faster than the common exp function but less accurate. //! Faster than the common exp function but less accurate.
//! From GLM_GTX_fast_exponential extension. //! From GLM_GTX_fast_exponential extension.

View File

@ -7,95 +7,66 @@
// File : glm/gtx/fast_exponential.inl // File : glm/gtx/fast_exponential.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ #include "../core/_vectorize.hpp"
// fastPow: namespace glm
template <typename T>
GLM_FUNC_QUALIFIER T fastPow(const T x, const T y)
{ {
// fastPow:
template <typename genType>
GLM_FUNC_QUALIFIER genType fastPow(genType const & x, genType const & y)
{
return exp(y * log(x)); return exp(y * log(x));
} }
template <typename T> VECTORIZE_VEC_VEC(fastPow)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
const detail::tvec2<T>& x,
const detail::tvec2<T>& y)
{
return detail::tvec2<T>(
fastPow(x.x, y.x),
fastPow(x.y, y.y));
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow( GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
const detail::tvec3<T>& x, {
const detail::tvec3<T>& y)
{
return detail::tvec3<T>(
fastPow(x.x, y.x),
fastPow(x.y, y.y),
fastPow(x.z, y.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
const detail::tvec4<T>& x,
const detail::tvec4<T>& y)
{
return detail::tvec4<T>(
fastPow(x.x, y.x),
fastPow(x.y, y.y),
fastPow(x.z, y.z),
fastPow(x.w, y.w));
}
template <typename T>
GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
{
T f = T(1); T f = T(1);
for(int i = 0; i < y; ++i) for(int i = 0; i < y; ++i)
f *= x; f *= x;
return f; return f;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
const detail::tvec2<T>& x, const detail::tvec2<T>& x,
const detail::tvec2<int>& y) const detail::tvec2<int>& y)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y)); fastPow(x.y, y.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
const detail::tvec3<T>& x, const detail::tvec3<T>& x,
const detail::tvec3<int>& y) const detail::tvec3<int>& y)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y), fastPow(x.y, y.y),
fastPow(x.z, y.z)); fastPow(x.z, y.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
const detail::tvec4<T>& x, const detail::tvec4<T>& x,
const detail::tvec4<int>& y) const detail::tvec4<int>& y)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y), fastPow(x.y, y.y),
fastPow(x.z, y.z), fastPow(x.z, y.z),
fastPow(x.w, y.w)); fastPow(x.w, y.w));
} }
// fastExp // fastExp
// Note: This function provides accurate results only for value between -1 and 1, else avoid it. // Note: This function provides accurate results only for value between -1 and 1, else avoid it.
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastExp(const T x) GLM_FUNC_QUALIFIER T fastExp(const T x)
{ {
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower. // This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); // return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
T x2 = x * x; T x2 = x * x;
@ -103,10 +74,10 @@ GLM_FUNC_QUALIFIER T fastExp(const T x)
T x4 = x3 * x; T x4 = x3 * x;
T x5 = x4 * x; T x5 = x4 * x;
return T(1) + x + (x2 * T(0.5)) + (x3 * T(0.1666666667)) + (x4 * T(0.041666667)) + (x5 * T(0.008333333333)); return T(1) + x + (x2 * T(0.5)) + (x3 * T(0.1666666667)) + (x4 * T(0.041666667)) + (x5 * T(0.008333333333));
} }
/* // Try to handle all values of float... but often shower than std::exp, glm::floor and the loop kill the performance /* // Try to handle all values of float... but often shower than std::exp, glm::floor and the loop kill the performance
GLM_FUNC_QUALIFIER float fastExp(float x) GLM_FUNC_QUALIFIER float fastExp(float x)
{ {
const float e = 2.718281828f; const float e = 2.718281828f;
const float IntegerPart = floor(x); const float IntegerPart = floor(x);
const float FloatPart = x - IntegerPart; const float FloatPart = x - IntegerPart;
@ -120,11 +91,11 @@ GLM_FUNC_QUALIFIER float fastExp(float x)
const float x4 = x3 * FloatPart; const float x4 = x3 * FloatPart;
const float x5 = x4 * FloatPart; const float x5 = x4 * FloatPart;
return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)); return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f));
} }
// Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers // Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers
GLM_FUNC_QUALIFIER float fastExp(float x) GLM_FUNC_QUALIFIER float fastExp(float x)
{ {
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower. // This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); // return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
float x2 = x * x; float x2 = x * x;
@ -135,156 +106,45 @@ GLM_FUNC_QUALIFIER float fastExp(float x)
float x7 = x6 * x; float x7 = x6 * x;
float x8 = x7 * x; float x8 = x7 * x;
return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)+ (x6 * 0.00138888888888f) + (x7 * 0.000198412698f) + (x8 * 0.0000248015873f);; return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)+ (x6 * 0.00138888888888f) + (x7 * 0.000198412698f) + (x8 * 0.0000248015873f);;
} }
*/ */
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastExp(x.x),
fastExp(x.y));
}
template <typename T> VECTORIZE_VEC(fastExp)
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp(
const detail::tvec3<T>& x)
{
return detail::tvec3<T>(
fastExp(x.x),
fastExp(x.y),
fastExp(x.z));
}
template <typename T> // fastLog
GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp( template <typename genType>
const detail::tvec4<T>& x) GLM_FUNC_QUALIFIER genType fastLog(genType const & x)
{ {
return detail::tvec4<T>(
fastExp(x.x),
fastExp(x.y),
fastExp(x.z),
fastExp(x.w));
}
// fastLog
template <typename T>
GLM_FUNC_QUALIFIER T fastLog(const T x)
{
return std::log(x); return std::log(x);
} }
/* Slower than the VC7.1 function... /* Slower than the VC7.1 function...
GLM_FUNC_QUALIFIER float fastLog(float x) GLM_FUNC_QUALIFIER float fastLog(float x)
{ {
float y1 = (x - 1.0f) / (x + 1.0f); float y1 = (x - 1.0f) / (x + 1.0f);
float y2 = y1 * y1; float y2 = y1 * y1;
return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f))); return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f)));
} }
*/ */
template <typename T> VECTORIZE_VEC(fastLog)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastLog(x.x),
fastLog(x.y));
}
template <typename T> //fastExp2, ln2 = 0.69314718055994530941723212145818f
GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog( template <typename genType>
const detail::tvec3<T>& x) GLM_FUNC_QUALIFIER genType fastExp2(genType const & x)
{ {
return detail::tvec3<T>(
fastLog(x.x),
fastLog(x.y),
fastLog(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastLog(x.x),
fastLog(x.y),
fastLog(x.z),
fastLog(x.w));
}
//fastExp2, ln2 = 0.69314718055994530941723212145818f
template <typename T>
GLM_FUNC_QUALIFIER T fastExp2(const T x)
{
return fastExp(0.69314718055994530941723212145818f * x); return fastExp(0.69314718055994530941723212145818f * x);
} }
template <typename T> VECTORIZE_VEC(fastExp2)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp2(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastExp2(x.x),
fastExp2(x.y));
}
template <typename T> // fastLog2, ln2 = 0.69314718055994530941723212145818f
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp2( template <typename genType>
const detail::tvec3<T>& x) GLM_FUNC_QUALIFIER genType fastLog2(genType const & x)
{ {
return detail::tvec3<T>(
fastExp2(x.x),
fastExp2(x.y),
fastExp2(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp2(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastExp2(x.x),
fastExp2(x.y),
fastExp2(x.z),
fastExp2(x.w));
}
// fastLog2, ln2 = 0.69314718055994530941723212145818f
template <typename T>
GLM_FUNC_QUALIFIER T fastLog2(const T x)
{
return fastLog(x) / 0.69314718055994530941723212145818f; return fastLog(x) / 0.69314718055994530941723212145818f;
} }
template <typename T> VECTORIZE_VEC(fastLog2)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog2(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastLog2(x.x),
fastLog2(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog2(
const detail::tvec3<T>& x)
{
return detail::tvec3<T>(
fastLog2(x.x),
fastLog2(x.y),
fastLog2(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog2(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastLog2(x.x),
fastLog2(x.y),
fastLog2(x.z),
fastLog2(x.w));
}
}//namespace glm }//namespace glm

View File

@ -2,267 +2,76 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2006-01-08 // Created : 2006-01-08
// Updated : 2006-01-08 // Updated : 2011-10-14
// Licence : This source is under MIT License // Licence : This source is under MIT License
// File : glm/gtx/fast_trigonometry.inl // File : glm/gtx/fast_trigonometry.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ #include "../core/_vectorize.hpp"
// sin namespace glm
template <typename T>
GLM_FUNC_QUALIFIER T fastSin(const T x)
{ {
// sin
template <typename T>
GLM_FUNC_QUALIFIER T fastSin(T const & x)
{
return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040)); return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040));
} }
template <typename T> VECTORIZE_VEC(fastSin)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastSin(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastSin(x.x),
fastSin(x.y));
}
template <typename T> // cos
GLM_FUNC_QUALIFIER detail::tvec3<T> fastSin( template <typename T>
const detail::tvec3<T>& x) GLM_FUNC_QUALIFIER T fastCos(T const & x)
{ {
return detail::tvec3<T>(
fastSin(x.x),
fastSin(x.y),
fastSin(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastSin(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastSin(x.x),
fastSin(x.y),
fastSin(x.z),
fastSin(x.w));
}
// cos
template <typename T>
GLM_FUNC_QUALIFIER T fastCos(const T x)
{
return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888)); return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888));
} }
template <typename T> VECTORIZE_VEC(fastCos)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastCos(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastCos(x.x),
fastCos(x.y));
}
template <typename T> // tan
GLM_FUNC_QUALIFIER detail::tvec3<T> fastCos( template <typename T>
const detail::tvec3<T>& x) GLM_FUNC_QUALIFIER T fastTan(T const & x)
{ {
return detail::tvec3<T>(
fastCos(x.x),
fastCos(x.y),
fastCos(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastCos(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastCos(x.x),
fastCos(x.y),
fastCos(x.z),
fastCos(x.w));
}
// tan
template <typename T>
GLM_FUNC_QUALIFIER T fastTan(const T x)
{
return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539)); return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539));
} }
template <typename T> VECTORIZE_VEC(fastTan)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastTan(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastTan(x.x),
fastTan(x.y));
}
template <typename T> // asin
GLM_FUNC_QUALIFIER detail::tvec3<T> fastTan( template <typename T>
const detail::tvec3<T>& x) GLM_FUNC_QUALIFIER T fastAsin(T const & x)
{ {
return detail::tvec3<T>(
fastTan(x.x),
fastTan(x.y),
fastTan(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastTan(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastTan(x.x),
fastTan(x.y),
fastTan(x.z),
fastTan(x.w));
}
// asin
template <typename T>
GLM_FUNC_QUALIFIER T fastAsin(const T x)
{
return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159)); return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159));
} }
template <typename T> detail::tvec2<T> fastAsin( VECTORIZE_VEC(fastAsin)
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastAsin(x.x),
fastAsin(x.y));
}
template <typename T> detail::tvec3<T> fastAsin( // acos
const detail::tvec3<T>& x) template <typename T>
{ GLM_FUNC_QUALIFIER T fastAcos(T const & x)
return detail::tvec3<T>( {
fastAsin(x.x),
fastAsin(x.y),
fastAsin(x.z));
}
template <typename T> detail::tvec4<T> fastAsin(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastAsin(x.x),
fastAsin(x.y),
fastAsin(x.z),
fastAsin(x.w));
}
// acos
template <typename T>
GLM_FUNC_QUALIFIER T fastAcos(const T x)
{
return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2) return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2)
} }
template <typename T> detail::tvec2<T> fastAcos( VECTORIZE_VEC(fastAcos)
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastAcos(x.x),
fastAcos(x.y));
}
template <typename T> detail::tvec3<T> fastAcos( // atan
const detail::tvec3<T>& x) template <typename T>
{ GLM_FUNC_QUALIFIER T fastAtan(T const & y, T const & x)
return detail::tvec3<T>( {
fastAcos(x.x),
fastAcos(x.y),
fastAcos(x.z));
}
template <typename T> detail::tvec4<T> fastAcos(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastAcos(x.x),
fastAcos(x.y),
fastAcos(x.z),
fastAcos(x.w));
}
// atan
template <typename T>
GLM_FUNC_QUALIFIER T fastAtan(const T y, const T x)
{
T sgn = sign(y) * sign(x); T sgn = sign(y) * sign(x);
return abs(fastAtan(y / x)) * sgn; return abs(fastAtan(y / x)) * sgn;
} }
template <typename T> VECTORIZE_VEC_VEC(fastAtan)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastAtan(
const detail::tvec2<T>& y,
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastAtan(y.x, x.x),
fastAtan(y.y, x.y));
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastAtan( GLM_FUNC_QUALIFIER T fastAtan(T const & x)
const detail::tvec3<T>& y, {
const detail::tvec3<T>& x)
{
return detail::tvec3<T>(
fastAtan(y.x, x.x),
fastAtan(y.y, x.y),
fastAtan(y.z, x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastAtan(
const detail::tvec4<T>& y,
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastAtan(y.x, x.x),
fastAtan(y.y, x.y),
fastAtan(y.z, x.z),
fastAtan(y.w, x.w));
}
template <typename T>
GLM_FUNC_QUALIFIER T fastAtan(const T x)
{
return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909)); return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909));
} }
template <typename T> VECTORIZE_VEC(fastAtan)
GLM_FUNC_QUALIFIER detail::tvec2<T> fastAtan(
const detail::tvec2<T>& x)
{
return detail::tvec2<T>(
fastAtan(x.x),
fastAtan(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastAtan(
const detail::tvec3<T>& x)
{
return detail::tvec3<T>(
fastAtan(x.x),
fastAtan(x.y),
fastAtan(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastAtan(
const detail::tvec4<T>& x)
{
return detail::tvec4<T>(
fastAtan(x.x),
fastAtan(x.y),
fastAtan(x.z),
fastAtan(x.w));
}
}//namespace glm }//namespace glm

View File

@ -7,17 +7,17 @@
// File : glm/gtx/gradient_paint.inl // File : glm/gtx/gradient_paint.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename valType> template <typename valType>
valType radialGradient valType radialGradient
( (
detail::tvec2<valType> const & Center, detail::tvec2<valType> const & Center,
valType const & Radius, valType const & Radius,
detail::tvec2<valType> const & Focal, detail::tvec2<valType> const & Focal,
detail::tvec2<valType> const & Position detail::tvec2<valType> const & Position
) )
{ {
detail::tvec2<valType> F = Focal - Center; detail::tvec2<valType> F = Focal - Center;
detail::tvec2<valType> D = Position - Focal; detail::tvec2<valType> D = Position - Focal;
valType Radius2 = pow2(Radius); valType Radius2 = pow2(Radius);
@ -27,18 +27,17 @@ valType radialGradient
valType Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x)); valType Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x));
valType Denominator = Radius2 - (Fx2 + Fy2); valType Denominator = Radius2 - (Fx2 + Fy2);
return Numerator / Denominator; return Numerator / Denominator;
} }
template <typename valType> template <typename valType>
valType linearGradient valType linearGradient
( (
detail::tvec2<valType> const & Point0, detail::tvec2<valType> const & Point0,
detail::tvec2<valType> const & Point1, detail::tvec2<valType> const & Point1,
detail::tvec2<valType> const & Position detail::tvec2<valType> const & Position
) )
{ {
detail::tvec2<valType> Dist = Point1 - Point0; detail::tvec2<valType> Dist = Point1 - Point0;
return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist);
} }
}//namespace glm }//namespace glm

View File

@ -7,24 +7,27 @@
// File : glm/gtx/handed_coordinate_space.inl // File : glm/gtx/handed_coordinate_space.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER bool rightHanded( GLM_FUNC_QUALIFIER bool rightHanded
(
detail::tvec3<T> const & tangent, detail::tvec3<T> const & tangent,
detail::tvec3<T> const & binormal, detail::tvec3<T> const & binormal,
detail::tvec3<T> const & normal) detail::tvec3<T> const & normal
{ )
{
return dot(cross(normal, tangent), binormal) > T(0); return dot(cross(normal, tangent), binormal) > T(0);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER bool leftHanded( GLM_FUNC_QUALIFIER bool leftHanded
(
detail::tvec3<T> const & tangent, detail::tvec3<T> const & tangent,
detail::tvec3<T> const & binormal, detail::tvec3<T> const & binormal,
detail::tvec3<T> const & normal) detail::tvec3<T> const & normal
{ )
{
return dot(cross(normal, tangent), binormal) < T(0); return dot(cross(normal, tangent), binormal) < T(0);
} }
}//namespace glm }//namespace glm

View File

@ -55,57 +55,57 @@ namespace glm
//! From GLM_GTX_inertia extension. //! From GLM_GTX_inertia extension.
template <typename T> template <typename T>
detail::tmat3x3<T> boxInertia3( detail::tmat3x3<T> boxInertia3(
const T Mass, T const & Mass,
const detail::tvec3<T>& Scale); detail::tvec3<T> const & Scale);
//! Build an inertia matrix for a box. //! Build an inertia matrix for a box.
//! From GLM_GTX_inertia extension. //! From GLM_GTX_inertia extension.
template <typename T> template <typename T>
detail::tmat4x4<T> boxInertia4( detail::tmat4x4<T> boxInertia4(
const T Mass, T const & Mass,
const detail::tvec3<T>& Scale); detail::tvec3<T> const & Scale);
//! Build an inertia matrix for a disk. //! Build an inertia matrix for a disk.
//! From GLM_GTX_inertia extension. //! From GLM_GTX_inertia extension.
template <typename T> template <typename T>
detail::tmat3x3<T> diskInertia3( detail::tmat3x3<T> diskInertia3(
const T Mass, T const & Mass,
const T Radius); T const & Radius);
//! Build an inertia matrix for a disk. //! Build an inertia matrix for a disk.
//! From GLM_GTX_inertia extension. //! From GLM_GTX_inertia extension.
template <typename T> template <typename T>
detail::tmat4x4<T> diskInertia4( detail::tmat4x4<T> diskInertia4(
const T Mass, T const & Mass,
const T Radius); T const & Radius);
//! Build an inertia matrix for a ball. //! Build an inertia matrix for a ball.
//! From GLM_GTX_inertia extension. //! From GLM_GTX_inertia extension.
template <typename T> template <typename T>
detail::tmat3x3<T> ballInertia3( detail::tmat3x3<T> ballInertia3(
const T Mass, T const & Mass,
const T Radius); T const & Radius);
//! Build an inertia matrix for a ball. //! Build an inertia matrix for a ball.
//! From GLM_GTX_inertia extension. //! From GLM_GTX_inertia extension.
template <typename T> template <typename T>
detail::tmat4x4<T> ballInertia4( detail::tmat4x4<T> ballInertia4(
const T Mass, T const & Mass,
const T Radius); T const & Radius);
//! Build an inertia matrix for a sphere. //! Build an inertia matrix for a sphere.
//! From GLM_GTX_inertia extension. //! From GLM_GTX_inertia extension.
template <typename T> template <typename T>
detail::tmat3x3<T> sphereInertia3( detail::tmat3x3<T> sphereInertia3(
const T Mass, T const & Mass,
const T Radius); T const & Radius);
//! Build an inertia matrix for a sphere. //! Build an inertia matrix for a sphere.
//! From GLM_GTX_inertia extension. //! From GLM_GTX_inertia extension.
template <typename T> template <typename T>
detail::tmat4x4<T> sphereInertia4( detail::tmat4x4<T> sphereInertia4(
const T Mass, T const & Mass,
const T Radius); T const & Radius);
/// @} /// @}
}// namespace glm }// namespace glm

View File

@ -7,93 +7,108 @@
// File : glm/gtx/inertia.inl // File : glm/gtx/inertia.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> boxInertia3(
const T Mass,
const detail::tvec3<T>& Scale)
{ {
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> boxInertia3
(
T const & Mass,
detail::tvec3<T> const & Scale
)
{
detail::tmat3x3<T> Result(T(1)); detail::tmat3x3<T> Result(T(1));
Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12);
Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12);
Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> boxInertia4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> boxInertia4
const T Mass, (
const detail::tvec3<T>& Scale) T const & Mass,
{ detail::tvec3<T> const & Scale
)
{
detail::tmat4x4<T> Result(T(1)); detail::tmat4x4<T> Result(T(1));
Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12);
Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12);
Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> diskInertia3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> diskInertia3
const T Mass, (
const T Radius) T const & Mass,
{ T const & Radius
)
{
T a = Mass * Radius * Radius / T(2); T a = Mass * Radius * Radius / T(2);
detail::tmat3x3<T> Result(a); detail::tmat3x3<T> Result(a);
Result[2][2] *= T(2); Result[2][2] *= T(2);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> diskInertia4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> diskInertia4
const T Mass, (
const T Radius) T const & Mass,
{ T const & Radius
)
{
T a = Mass * Radius * Radius / T(2); T a = Mass * Radius * Radius / T(2);
detail::tmat4x4<T> Result(a); detail::tmat4x4<T> Result(a);
Result[2][2] *= T(2); Result[2][2] *= T(2);
Result[3][3] = T(1); Result[3][3] = T(1);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> ballInertia3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> ballInertia3
const T Mass, (
const T Radius) T const & Mass,
{ T const & Radius
)
{
T a = T(2) * Mass * Radius * Radius / T(5); T a = T(2) * Mass * Radius * Radius / T(5);
return detail::tmat3x3<T>(a); return detail::tmat3x3<T>(a);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> ballInertia4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> ballInertia4
const T Mass, (
const T Radius) T const & Mass,
{ T const & Radius
)
{
T a = T(2) * Mass * Radius * Radius / T(5); T a = T(2) * Mass * Radius * Radius / T(5);
detail::tmat4x4<T> Result(a); detail::tmat4x4<T> Result(a);
Result[3][3] = T(1); Result[3][3] = T(1);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> sphereInertia3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> sphereInertia3
const T Mass, (
const T Radius) T const & Mass,
{ T const & Radius
)
{
T a = T(2) * Mass * Radius * Radius / T(3); T a = T(2) * Mass * Radius * Radius / T(3);
return detail::tmat3x3<T>(a); return detail::tmat3x3<T>(a);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> sphereInertia4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> sphereInertia4
const T Mass, (
const T Radius) T const & Mass,
{ T const & Radius
)
{
T a = T(2) * Mass * Radius * Radius / T(3); T a = T(2) * Mass * Radius * Radius / T(3);
detail::tmat4x4<T> Result(a); detail::tmat4x4<T> Result(a);
Result[3][3] = T(1); Result[3][3] = T(1);
return Result; return Result;
} }
}//namespace glm }//namespace glm

View File

@ -7,11 +7,13 @@
// File : glm/gtx/int_10_10_10_2.inl // File : glm/gtx/int_10_10_10_2.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast(glm::vec4 const & v)
{ {
GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast
(
glm::vec4 const & v
)
{
return dword(uint(v.x * 2047.f) << 0 | uint(v.y * 2047.f) << 10 | uint(v.z * 2047.f) << 20 | uint(v.w * 3.f) << 30); return dword(uint(v.x * 2047.f) << 0 | uint(v.y * 2047.f) << 10 | uint(v.z * 2047.f) << 20 | uint(v.w * 3.f) << 30);
} }
}//namespace glm }//namespace glm

View File

@ -7,22 +7,22 @@
// File : glm/gtx/integer.inl // File : glm/gtx/integer.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
// pow
GLM_FUNC_QUALIFIER int pow(int x, int y)
{ {
// pow
GLM_FUNC_QUALIFIER int pow(int x, int y)
{
if(y == 0) if(y == 0)
return 1; return 1;
int result = x; int result = x;
for(int i = 1; i < y; ++i) for(int i = 1; i < y; ++i)
result *= x; result *= x;
return result; return result;
} }
// sqrt: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387 // sqrt: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387
GLM_FUNC_QUALIFIER int sqrt(int x) GLM_FUNC_QUALIFIER int sqrt(int x)
{ {
if(x <= 1) return x; if(x <= 1) return x;
int NextTrial = x >> 1; int NextTrial = x >> 1;
@ -35,7 +35,7 @@ GLM_FUNC_QUALIFIER int sqrt(int x)
} while(NextTrial < CurrentAnswer); } while(NextTrial < CurrentAnswer);
return CurrentAnswer; return CurrentAnswer;
} }
// Henry Gordon Dietz: http://aggregate.org/MAGIC/ // Henry Gordon Dietz: http://aggregate.org/MAGIC/
namespace detail namespace detail
@ -69,9 +69,9 @@ namespace detail
}; };
}//namespace detail }//namespace detail
// Henry Gordon Dietz: http://aggregate.org/MAGIC/ // Henry Gordon Dietz: http://aggregate.org/MAGIC/
unsigned int floor_log2(unsigned int x) unsigned int floor_log2(unsigned int x)
{ {
x |= (x >> 1); x |= (x >> 1);
x |= (x >> 2); x |= (x >> 2);
x |= (x >> 4); x |= (x >> 4);
@ -79,65 +79,65 @@ unsigned int floor_log2(unsigned int x)
x |= (x >> 16); x |= (x >> 16);
return(detail::ones32(x) - 1); return(detail::ones32(x) - 1);
} }
// mod // mod
GLM_FUNC_QUALIFIER int mod(int x, int y) GLM_FUNC_QUALIFIER int mod(int x, int y)
{ {
return x - y * (x / y); return x - y * (x / y);
} }
// factorial (!12 max, integer only) // factorial (!12 max, integer only)
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType factorial(genType const & x) GLM_FUNC_QUALIFIER genType factorial(genType const & x)
{ {
genType Temp = x; genType Temp = x;
genType Result; genType Result;
for(Result = 1; Temp > 1; --Temp) for(Result = 1; Temp > 1; --Temp)
Result *= Temp; Result *= Temp;
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> factorial( GLM_FUNC_QUALIFIER detail::tvec2<valType> factorial(
detail::tvec2<valType> const & x) detail::tvec2<valType> const & x)
{ {
return detail::tvec2<valType>( return detail::tvec2<valType>(
factorial(x.x), factorial(x.x),
factorial(x.y)); factorial(x.y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> factorial( GLM_FUNC_QUALIFIER detail::tvec3<valType> factorial(
detail::tvec3<valType> const & x) detail::tvec3<valType> const & x)
{ {
return detail::tvec3<valType>( return detail::tvec3<valType>(
factorial(x.x), factorial(x.x),
factorial(x.y), factorial(x.y),
factorial(x.z)); factorial(x.z));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> factorial( GLM_FUNC_QUALIFIER detail::tvec4<valType> factorial(
detail::tvec4<valType> const & x) detail::tvec4<valType> const & x)
{ {
return detail::tvec4<valType>( return detail::tvec4<valType>(
factorial(x.x), factorial(x.x),
factorial(x.y), factorial(x.y),
factorial(x.z), factorial(x.z),
factorial(x.w)); factorial(x.w));
} }
GLM_FUNC_QUALIFIER uint pow(uint x, uint y) GLM_FUNC_QUALIFIER uint pow(uint x, uint y)
{ {
uint result = x; uint result = x;
for(uint i = 1; i < y; ++i) for(uint i = 1; i < y; ++i)
result *= x; result *= x;
return result; return result;
} }
GLM_FUNC_QUALIFIER uint sqrt(uint x) GLM_FUNC_QUALIFIER uint sqrt(uint x)
{ {
if(x <= 1) return x; if(x <= 1) return x;
uint NextTrial = x >> 1; uint NextTrial = x >> 1;
@ -150,25 +150,25 @@ GLM_FUNC_QUALIFIER uint sqrt(uint x)
} while(NextTrial < CurrentAnswer); } while(NextTrial < CurrentAnswer);
return CurrentAnswer; return CurrentAnswer;
} }
GLM_FUNC_QUALIFIER uint mod(uint x, uint y) GLM_FUNC_QUALIFIER uint mod(uint x, uint y)
{ {
return x - y * (x / y); return x - y * (x / y);
} }
#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC)) #if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC))
GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x) GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x)
{ {
return 31u - findMSB(x); return 31u - findMSB(x);
} }
#else #else
// Hackers Delight: http://www.hackersdelight.org/HDcode/nlz.c.txt // Hackers Delight: http://www.hackersdelight.org/HDcode/nlz.c.txt
GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x) GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x)
{ {
int y, m, n; int y, m, n;
y = -int(x >> 16); // If left half of x is 0, y = -int(x >> 16); // If left half of x is 0,
@ -194,7 +194,7 @@ GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x)
y = x >> 14; // Set y = 0, 1, 2, or 3. y = x >> 14; // Set y = 0, 1, 2, or 3.
m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp. m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp.
return unsigned(n + 2 - m); return unsigned(n + 2 - m);
} }
#endif//(GLM_COMPILER) #endif//(GLM_COMPILER)

View File

@ -10,16 +10,16 @@
#include <cfloat> #include <cfloat>
#include <limits> #include <limits>
namespace glm{ namespace glm
{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool intersectRayTriangle GLM_FUNC_QUALIFIER bool intersectRayTriangle
( (
genType const & orig, genType const & dir, genType const & orig, genType const & dir,
genType const & v0, genType const & v1, genType const & v2, genType const & v0, genType const & v1, genType const & v2,
genType & baryPosition genType & baryPosition
) )
{ {
genType e1 = v1 - v0; genType e1 = v1 - v0;
genType e2 = v2 - v0; genType e2 = v2 - v0;
@ -50,53 +50,53 @@ GLM_FUNC_QUALIFIER bool intersectRayTriangle
baryPosition.z = f * glm::dot(e2, q); baryPosition.z = f * glm::dot(e2, q);
return baryPosition.z >= typename genType::value_type(0.0f); return baryPosition.z >= typename genType::value_type(0.0f);
} }
//template <typename genType> //template <typename genType>
//GLM_FUNC_QUALIFIER bool intersectRayTriangle //GLM_FUNC_QUALIFIER bool intersectRayTriangle
//( //(
// genType const & orig, genType const & dir, // genType const & orig, genType const & dir,
// genType const & vert0, genType const & vert1, genType const & vert2, // genType const & vert0, genType const & vert1, genType const & vert2,
// genType & position // genType & position
//) //)
//{ //{
// typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); // typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
// //
// genType edge1 = vert1 - vert0; // genType edge1 = vert1 - vert0;
// genType edge2 = vert2 - vert0; // genType edge2 = vert2 - vert0;
// //
// genType pvec = cross(dir, edge2); // genType pvec = cross(dir, edge2);
// //
// float det = dot(edge1, pvec); // float det = dot(edge1, pvec);
// if(det < Epsilon) // if(det < Epsilon)
// return false; // return false;
// //
// genType tvec = orig - vert0; // genType tvec = orig - vert0;
// //
// position.y = dot(tvec, pvec); // position.y = dot(tvec, pvec);
// if (position.y < typename genType::value_type(0) || position.y > det) // if (position.y < typename genType::value_type(0) || position.y > det)
// return typename genType::value_type(0); // return typename genType::value_type(0);
// //
// genType qvec = cross(tvec, edge1); // genType qvec = cross(tvec, edge1);
// //
// position.z = dot(dir, qvec); // position.z = dot(dir, qvec);
// if (position.z < typename genType::value_type(0) || position.y + position.z > det) // if (position.z < typename genType::value_type(0) || position.y + position.z > det)
// return typename genType::value_type(0); // return typename genType::value_type(0);
// //
// position.x = dot(edge2, qvec); // position.x = dot(edge2, qvec);
// position *= typename genType::value_type(1) / det; // position *= typename genType::value_type(1) / det;
// //
// return typename genType::value_type(1); // return typename genType::value_type(1);
//} //}
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool intersectLineTriangle GLM_FUNC_QUALIFIER bool intersectLineTriangle
( (
genType const & orig, genType const & dir, genType const & orig, genType const & dir,
genType const & vert0, genType const & vert1, genType const & vert2, genType const & vert0, genType const & vert1, genType const & vert2,
genType & position genType & position
) )
{ {
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
genType edge1 = vert1 - vert0; genType edge1 = vert1 - vert0;
@ -125,16 +125,16 @@ GLM_FUNC_QUALIFIER bool intersectLineTriangle
position.x = dot(edge2, qvec) * inv_det; position.x = dot(edge2, qvec) * inv_det;
return true; return true;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool intersectRaySphere GLM_FUNC_QUALIFIER bool intersectRaySphere
( (
genType const & rayStarting, genType const & rayDirection, genType const & rayStarting, genType const & rayDirection,
genType const & sphereCenter, typename genType::value_type sphereRadius, genType const & sphereCenter, typename genType::value_type sphereRadius,
genType & position, genType & normal genType & position, genType & normal
) )
{ {
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
typename genType::value_type a = dot(rayDirection, rayDirection); typename genType::value_type a = dot(rayDirection, rayDirection);
@ -158,16 +158,16 @@ GLM_FUNC_QUALIFIER bool intersectRaySphere
return true; return true;
} }
return false; return false;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool intersectLineSphere GLM_FUNC_QUALIFIER bool intersectLineSphere
( (
genType const & point0, genType const & point1, genType const & point0, genType const & point1,
genType const & center, typename genType::value_type radius, genType const & center, typename genType::value_type radius,
genType & position, genType & normal genType & position, genType & normal
) )
{ {
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
genType dir = point1 - point0; genType dir = point1 - point0;
@ -192,6 +192,5 @@ GLM_FUNC_QUALIFIER bool intersectLineSphere
return true; return true;
} }
return false; return false;
} }
}//namespace glm }//namespace glm

View File

@ -7,82 +7,20 @@
// File : glm/gtx/log_base.inl // File : glm/gtx/log_base.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ #include "../core/_vectorize.hpp"
template <typename genType> namespace glm
GLM_FUNC_QUALIFIER genType log( {
template <typename genType>
GLM_FUNC_QUALIFIER genType log(
genType const & x, genType const & x,
genType const & base) genType const & base)
{ {
assert(x != genType(0)); assert(x != genType(0));
return glm::log(x) / glm::log(base); return glm::log(x) / glm::log(base);
} }
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> log(
detail::tvec2<valType> const & v,
valType const & base)
{
return detail::tvec2<valType>(
log(v.x, base),
log(v.y, base));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> log(
detail::tvec3<valType> const & v,
valType const & base)
{
return detail::tvec3<valType>(
log(v.x, base),
log(v.y, base),
log(v.z, base));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> log(
detail::tvec4<valType> const & v,
valType const & base)
{
return detail::tvec4<valType>(
log(v.x, base),
log(v.y, base),
log(v.z, base),
log(v.w, base));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> log(
detail::tvec2<valType> const & v,
detail::tvec2<valType> const & base)
{
return detail::tvec2<valType>(
log(v.x, base.x),
log(v.y, base.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> log(
detail::tvec3<valType> const & v,
detail::tvec3<valType> const & base)
{
return detail::tvec3<valType>(
log(v.x, base.x),
log(v.y, base.y),
log(v.z, base.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> log(
detail::tvec4<valType> const & v,
detail::tvec4<valType> const & base)
{
return detail::tvec4<valType>(
log(v.x, base.x),
log(v.y, base.y),
log(v.z, base.z),
log(v.w, base.w));
}
VECTORIZE_VEC_SCA(log)
VECTORIZE_VEC_VEC(log)
}//namespace glm }//namespace glm

View File

@ -7,12 +7,14 @@
// File : glm/gtx/matrix_cross_product.inl // File : glm/gtx/matrix_cross_product.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> matrixCross3(
detail::tvec3<T> const & x)
{ {
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> matrixCross3
(
detail::tvec3<T> const & x
)
{
detail::tmat3x3<T> Result(T(0)); detail::tmat3x3<T> Result(T(0));
Result[0][1] = x.z; Result[0][1] = x.z;
Result[1][0] = -x.z; Result[1][0] = -x.z;
@ -21,12 +23,14 @@ GLM_FUNC_QUALIFIER detail::tmat3x3<T> matrixCross3(
Result[1][2] = x.x; Result[1][2] = x.x;
Result[2][1] = -x.x; Result[2][1] = -x.x;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> matrixCross4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> matrixCross4
detail::tvec3<T> const & x) (
{ detail::tvec3<T> const & x
)
{
detail::tmat4x4<T> Result(T(0)); detail::tmat4x4<T> Result(T(0));
Result[0][1] = x.z; Result[0][1] = x.z;
Result[1][0] = -x.z; Result[1][0] = -x.z;
@ -35,6 +39,6 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> matrixCross4(
Result[1][2] = x.x; Result[1][2] = x.x;
Result[2][1] = -x.x; Result[2][1] = -x.x;
return Result; return Result;
} }
}//namespace glm }//namespace glm

View File

@ -7,14 +7,16 @@
// File : glm/gtx/matrix_interpolation.inl // File : glm/gtx/matrix_interpolation.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER void axisAngle( GLM_FUNC_QUALIFIER void axisAngle
(
detail::tmat4x4<T> const & mat, detail::tmat4x4<T> const & mat,
detail::tvec3<T> & axis, detail::tvec3<T> & axis,
T & angle) T & angle
{ )
{
T epsilon = (T)0.01; T epsilon = (T)0.01;
T epsilon2 = (T)0.1; T epsilon2 = (T)0.1;
@ -73,13 +75,15 @@ GLM_FUNC_QUALIFIER void axisAngle(
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;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> axisAngleMatrix( GLM_FUNC_QUALIFIER detail::tmat4x4<T> axisAngleMatrix
(
detail::tvec3<T> const & axis, detail::tvec3<T> const & axis,
T const angle) T const angle
{ )
{
T c = cos(angle); T c = cos(angle);
T s = sin(angle); T s = sin(angle);
T t = T(1) - c; T t = T(1) - c;
@ -91,14 +95,16 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> axisAngleMatrix(
t * n.x * n.z + n.y * s, t * n.y * n.z - n.x * s, t * n.z * n.z + c, T(0), t * n.x * n.z + n.y * s, t * n.y * n.z - n.x * s, t * n.z * n.z + c, T(0),
T(0), T(0), T(0), T(1) T(0), T(0), T(0), T(1)
); );
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> interpolate( GLM_FUNC_QUALIFIER detail::tmat4x4<T> interpolate
(
detail::tmat4x4<T> const & m1, detail::tmat4x4<T> const & m1,
detail::tmat4x4<T> const & m2, detail::tmat4x4<T> const & m2,
T const delta) T const delta
{ )
{
detail::tmat4x4<T> dltRotation = m2 * transpose(m1); detail::tmat4x4<T> dltRotation = m2 * transpose(m1);
detail::tvec3<T> dltAxis; detail::tvec3<T> dltAxis;
T dltAngle; T dltAngle;
@ -108,6 +114,5 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> interpolate(
out[3][1] = m1[3][1] + delta * (m2[3][1] - m1[3][1]); out[3][1] = m1[3][1] + delta * (m2[3][1] - m1[3][1]);
out[3][2] = m1[3][2] + delta * (m2[3][2] - m1[3][2]); out[3][2] = m1[3][2] + delta * (m2[3][2] - m1[3][2]);
return out; return out;
} }
}//namespace glm }//namespace glm

View File

@ -55,85 +55,85 @@ namespace glm
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat2x2<T> rowMajor2( detail::tmat2x2<T> rowMajor2(
const detail::tvec2<T>& v1, detail::tvec2<T> const & v1,
const detail::tvec2<T>& v2); detail::tvec2<T> const & v2);
//! Build a row major matrix from other matrix. //! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat2x2<T> rowMajor2( detail::tmat2x2<T> rowMajor2(
const detail::tmat2x2<T>& m); detail::tmat2x2<T> const & m);
//! Build a row major matrix from row vectors. //! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat3x3<T> rowMajor3( detail::tmat3x3<T> rowMajor3(
const detail::tvec3<T>& v1, detail::tvec3<T> const & v1,
const detail::tvec3<T>& v2, detail::tvec3<T> const & v2,
const detail::tvec3<T>& v3); detail::tvec3<T> const & v3);
//! Build a row major matrix from other matrix. //! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat3x3<T> rowMajor3( detail::tmat3x3<T> rowMajor3(
const detail::tmat3x3<T>& m); detail::tmat3x3<T> const & m);
//! Build a row major matrix from row vectors. //! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat4x4<T> rowMajor4( detail::tmat4x4<T> rowMajor4(
const detail::tvec4<T>& v1, detail::tvec4<T> const & v1,
const detail::tvec4<T>& v2, detail::tvec4<T> const & v2,
const detail::tvec4<T>& v3, detail::tvec4<T> const & v3,
const detail::tvec4<T>& v4); detail::tvec4<T> const & v4);
//! Build a row major matrix from other matrix. //! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat4x4<T> rowMajor4( detail::tmat4x4<T> rowMajor4(
const detail::tmat4x4<T>& m); detail::tmat4x4<T> const & m);
//! Build a column major matrix from column vectors. //! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat2x2<T> colMajor2( detail::tmat2x2<T> colMajor2(
const detail::tvec2<T>& v1, detail::tvec2<T> const & v1,
const detail::tvec2<T>& v2); detail::tvec2<T> const & v2);
//! Build a column major matrix from other matrix. //! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat2x2<T> colMajor2( detail::tmat2x2<T> colMajor2(
const detail::tmat2x2<T>& m); detail::tmat2x2<T> const & m);
//! Build a column major matrix from column vectors. //! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat3x3<T> colMajor3( detail::tmat3x3<T> colMajor3(
const detail::tvec3<T>& v1, detail::tvec3<T> const & v1,
const detail::tvec3<T>& v2, detail::tvec3<T> const & v2,
const detail::tvec3<T>& v3); detail::tvec3<T> const & v3);
//! Build a column major matrix from other matrix. //! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat3x3<T> colMajor3( detail::tmat3x3<T> colMajor3(
const detail::tmat3x3<T>& m); detail::tmat3x3<T> const & m);
//! Build a column major matrix from column vectors. //! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat4x4<T> colMajor4( detail::tmat4x4<T> colMajor4(
const detail::tvec4<T>& v1, detail::tvec4<T> const & v1,
const detail::tvec4<T>& v2, detail::tvec4<T> const & v2,
const detail::tvec4<T>& v3, detail::tvec4<T> const & v3,
const detail::tvec4<T>& v4); detail::tvec4<T> const & v4);
//! Build a column major matrix from other matrix. //! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension. //! From GLM_GTX_matrix_major_storage extension.
template <typename T> template <typename T>
detail::tmat4x4<T> colMajor4( detail::tmat4x4<T> colMajor4(
const detail::tmat4x4<T>& m); detail::tmat4x4<T> const & m);
/// @} /// @}
}//namespace glm }//namespace glm

View File

@ -7,39 +7,41 @@
// File : glm/gtx/matrix_major_storage.inl // File : glm/gtx/matrix_major_storage.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2(
const detail::tvec2<T>& v1,
const detail::tvec2<T>& v2)
{ {
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2
(
detail::tvec2<T> const & v1,
detail::tvec2<T> const & v2
)
{
detail::tmat2x2<T> Result; detail::tmat2x2<T> Result;
Result[0][0] = v1.x; Result[0][0] = v1.x;
Result[1][0] = v1.y; Result[1][0] = v1.y;
Result[0][1] = v2.x; Result[0][1] = v2.x;
Result[1][1] = v2.y; Result[1][1] = v2.y;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2( GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2(
const detail::tmat2x2<T>& m) const detail::tmat2x2<T>& m)
{ {
detail::tmat2x2<T> Result; detail::tmat2x2<T> Result;
Result[0][0] = m[0][0]; Result[0][0] = m[0][0];
Result[0][1] = m[1][0]; Result[0][1] = m[1][0];
Result[1][0] = m[0][1]; Result[1][0] = m[0][1];
Result[1][1] = m[1][1]; Result[1][1] = m[1][1];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
const detail::tvec3<T>& v1, const detail::tvec3<T>& v1,
const detail::tvec3<T>& v2, const detail::tvec3<T>& v2,
const detail::tvec3<T>& v3) const detail::tvec3<T>& v3)
{ {
detail::tmat3x3<T> Result; detail::tmat3x3<T> Result;
Result[0][0] = v1.x; Result[0][0] = v1.x;
Result[1][0] = v1.y; Result[1][0] = v1.y;
@ -51,12 +53,12 @@ GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
Result[1][2] = v3.y; Result[1][2] = v3.y;
Result[2][2] = v3.z; Result[2][2] = v3.z;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
const detail::tmat3x3<T>& m) const detail::tmat3x3<T>& m)
{ {
detail::tmat3x3<T> Result; detail::tmat3x3<T> Result;
Result[0][0] = m[0][0]; Result[0][0] = m[0][0];
Result[0][1] = m[1][0]; Result[0][1] = m[1][0];
@ -68,15 +70,15 @@ GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
Result[2][1] = m[1][2]; Result[2][1] = m[1][2];
Result[2][2] = m[2][2]; Result[2][2] = m[2][2];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
const detail::tvec4<T>& v1, const detail::tvec4<T>& v1,
const detail::tvec4<T>& v2, const detail::tvec4<T>& v2,
const detail::tvec4<T>& v3, const detail::tvec4<T>& v3,
const detail::tvec4<T>& v4) const detail::tvec4<T>& v4)
{ {
detail::tmat4x4<T> Result; detail::tmat4x4<T> Result;
Result[0][0] = v1.x; Result[0][0] = v1.x;
Result[1][0] = v1.y; Result[1][0] = v1.y;
@ -95,12 +97,12 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
Result[2][3] = v4.z; Result[2][3] = v4.z;
Result[3][3] = v4.w; Result[3][3] = v4.w;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
const detail::tmat4x4<T>& m) const detail::tmat4x4<T>& m)
{ {
detail::tmat4x4<T> Result; detail::tmat4x4<T> Result;
Result[0][0] = m[0][0]; Result[0][0] = m[0][0];
Result[0][1] = m[1][0]; Result[0][1] = m[1][0];
@ -119,54 +121,53 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
Result[3][2] = m[2][3]; Result[3][2] = m[2][3];
Result[3][3] = m[3][3]; Result[3][3] = m[3][3];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2( GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2(
const detail::tvec2<T>& v1, const detail::tvec2<T>& v1,
const detail::tvec2<T>& v2) const detail::tvec2<T>& v2)
{ {
return detail::tmat2x2<T>(v1, v2); return detail::tmat2x2<T>(v1, v2);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2( GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2(
const detail::tmat2x2<T>& m) const detail::tmat2x2<T>& m)
{ {
return detail::tmat2x2<T>(m); return detail::tmat2x2<T>(m);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3(
const detail::tvec3<T>& v1, const detail::tvec3<T>& v1,
const detail::tvec3<T>& v2, const detail::tvec3<T>& v2,
const detail::tvec3<T>& v3) const detail::tvec3<T>& v3)
{ {
return detail::tmat3x3<T>(v1, v2, v3); return detail::tmat3x3<T>(v1, v2, v3);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3(
const detail::tmat3x3<T>& m) const detail::tmat3x3<T>& m)
{ {
return detail::tmat3x3<T>(m); return detail::tmat3x3<T>(m);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4(
const detail::tvec4<T>& v1, const detail::tvec4<T>& v1,
const detail::tvec4<T>& v2, const detail::tvec4<T>& v2,
const detail::tvec4<T>& v3, const detail::tvec4<T>& v3,
const detail::tvec4<T>& v4) const detail::tvec4<T>& v4)
{ {
return detail::tmat4x4<T>(v1, v2, v3, v4); return detail::tmat4x4<T>(v1, v2, v3, v4);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4(
const detail::tmat4x4<T>& m) const detail::tmat4x4<T>& m)
{ {
return detail::tmat4x4<T>(m); return detail::tmat4x4<T>(m);
} }
}//namespace glm }//namespace glm

View File

@ -7,119 +7,118 @@
// File : glm/gtx/matrix_operation.inl // File : glm/gtx/matrix_operation.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> diagonal2x2
(
detail::tvec2<valType> const & v
)
{ {
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> diagonal2x2
(
detail::tvec2<valType> const & v
)
{
detail::tmat2x2<valType> Result(valType(1)); detail::tmat2x2<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x3<valType> diagonal2x3 GLM_FUNC_QUALIFIER detail::tmat2x3<valType> diagonal2x3
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat2x3<valType> Result(valType(1)); detail::tmat2x3<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x4<valType> diagonal2x4 GLM_FUNC_QUALIFIER detail::tmat2x4<valType> diagonal2x4
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat2x4<valType> Result(valType(1)); detail::tmat2x4<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x2<valType> diagonal3x2 GLM_FUNC_QUALIFIER detail::tmat3x2<valType> diagonal3x2
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat3x2<valType> Result(valType(1)); detail::tmat3x2<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> diagonal3x3 GLM_FUNC_QUALIFIER detail::tmat3x3<valType> diagonal3x3
( (
detail::tvec3<valType> const & v detail::tvec3<valType> const & v
) )
{ {
detail::tmat3x3<valType> Result(valType(1)); detail::tmat3x3<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
Result[2][2] = v[2]; Result[2][2] = v[2];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x4<valType> diagonal3x4 GLM_FUNC_QUALIFIER detail::tmat3x4<valType> diagonal3x4
( (
detail::tvec3<valType> const & v detail::tvec3<valType> const & v
) )
{ {
detail::tmat3x4<valType> Result(valType(1)); detail::tmat3x4<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
Result[2][2] = v[2]; Result[2][2] = v[2];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> diagonal4x4 GLM_FUNC_QUALIFIER detail::tmat4x4<valType> diagonal4x4
( (
detail::tvec4<valType> const & v detail::tvec4<valType> const & v
) )
{ {
detail::tmat4x4<valType> Result(valType(1)); detail::tmat4x4<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
Result[2][2] = v[2]; Result[2][2] = v[2];
Result[3][3] = v[3]; Result[3][3] = v[3];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x3<valType> diagonal4x3 GLM_FUNC_QUALIFIER detail::tmat4x3<valType> diagonal4x3
( (
detail::tvec3<valType> const & v detail::tvec3<valType> const & v
) )
{ {
detail::tmat4x3<valType> Result(valType(1)); detail::tmat4x3<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
Result[2][2] = v[2]; Result[2][2] = v[2];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x2<valType> diagonal4x2 GLM_FUNC_QUALIFIER detail::tmat4x2<valType> diagonal4x2
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat4x2<valType> Result(valType(1)); detail::tmat4x2<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
}//namespace glm }//namespace glm

View File

@ -56,57 +56,57 @@ namespace glm
//! From GLM_GTX_matrix_query extension. //! From GLM_GTX_matrix_query extension.
template<typename T> template<typename T>
bool isNull( bool isNull(
const detail::tmat2x2<T>& m, detail::tmat2x2<T> const & m,
const T epsilon = std::numeric_limits<T>::epsilon()); T const & epsilon = std::numeric_limits<T>::epsilon());
//! Return if a matrix a null matrix. //! Return if a matrix a null matrix.
//! From GLM_GTX_matrix_query extension. //! From GLM_GTX_matrix_query extension.
template<typename T> template<typename T>
bool isNull( bool isNull(
const detail::tmat3x3<T>& m, detail::tmat3x3<T> const & m,
const T epsilon = std::numeric_limits<T>::epsilon()); T const & epsilon = std::numeric_limits<T>::epsilon());
//! Return if a matrix a null matrix. //! Return if a matrix a null matrix.
//! From GLM_GTX_matrix_query extension. //! From GLM_GTX_matrix_query extension.
template<typename T> template<typename T>
bool isNull( bool isNull(
const detail::tmat4x4<T>& m, detail::tmat4x4<T> const & m,
const T epsilon = std::numeric_limits<T>::epsilon()); T const & epsilon = std::numeric_limits<T>::epsilon());
//! Return if a matrix an identity matrix. //! Return if a matrix an identity matrix.
//! From GLM_GTX_matrix_query extension. //! From GLM_GTX_matrix_query extension.
template<typename genType> template<typename genType>
bool isIdentity( bool isIdentity(
const genType& m, genType const & m,
const typename genType::value_type epsilon = std::numeric_limits<typename genType::value_type>::epsilon()); typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
//! Return if a matrix a normalized matrix. //! Return if a matrix a normalized matrix.
//! From GLM_GTX_matrix_query extension. //! From GLM_GTX_matrix_query extension.
template<typename T> template<typename T>
bool isNormalized( bool isNormalized(
const detail::tmat2x2<T>& m, detail::tmat2x2<T> const & m,
const T epsilon = std::numeric_limits<T>::epsilon()); T const & epsilon = std::numeric_limits<T>::epsilon());
//! Return if a matrix a normalized matrix. //! Return if a matrix a normalized matrix.
//! From GLM_GTX_matrix_query extension. //! From GLM_GTX_matrix_query extension.
template<typename T> template<typename T>
bool isNormalized( bool isNormalized(
const detail::tmat3x3<T>& m, detail::tmat3x3<T> const & m,
const T epsilon = std::numeric_limits<T>::epsilon()); T const & epsilon = std::numeric_limits<T>::epsilon());
//! Return if a matrix a normalized matrix. //! Return if a matrix a normalized matrix.
//! From GLM_GTX_matrix_query extension. //! From GLM_GTX_matrix_query extension.
template<typename T> template<typename T>
bool isNormalized( bool isNormalized(
const detail::tmat4x4<T>& m, detail::tmat4x4<T> const & m,
const T epsilon = std::numeric_limits<T>::epsilon()); T const & epsilon = std::numeric_limits<T>::epsilon());
//! Return if a matrix an orthonormalized matrix. //! Return if a matrix an orthonormalized matrix.
//! From GLM_GTX_matrix_query extension. //! From GLM_GTX_matrix_query extension.
template<typename genType> template<typename genType>
bool isOrthogonal( bool isOrthogonal(
const genType& m, genType const & m,
const typename genType::value_type epsilon = std::numeric_limits<typename genType::value_type>::epsilon()); typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
/// @} /// @}
}//namespace glm }//namespace glm

View File

@ -10,46 +10,53 @@
// - GLM core // - GLM core
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template<typename T>
GLM_FUNC_QUALIFIER bool isNull(
const detail::tmat2x2<T>& m,
const T epsilon)
{ {
template<typename T>
GLM_FUNC_QUALIFIER bool isNull
(
detail::tmat2x2<T> const & m,
T const & epsilon)
{
bool result = true; bool result = true;
for(int i = 0; result && i < 2 ; ++i) for(int i = 0; result && i < 2 ; ++i)
result = isNull(m[i], epsilon); result = isNull(m[i], epsilon);
return result; return result;
} }
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER bool isNull( GLM_FUNC_QUALIFIER bool isNull
const detail::tmat3x3<T>& m, (
const T epsilon) detail::tmat3x3<T> const & m,
{ T const & epsilon
)
{
bool result = true; bool result = true;
for(int i = 0; result && i < 3 ; ++i) for(int i = 0; result && i < 3 ; ++i)
result = isNull(m[i], epsilon); result = isNull(m[i], epsilon);
return result; return result;
} }
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER bool isNull( GLM_FUNC_QUALIFIER bool isNull
const detail::tmat4x4<T>& m, (
const T epsilon) detail::tmat4x4<T> const & m,
{ T const & epsilon
)
{
bool result = true; bool result = true;
for(int i = 0; result && i < 4 ; ++i) for(int i = 0; result && i < 4 ; ++i)
result = isNull(m[i], epsilon); result = isNull(m[i], epsilon);
return result; return result;
} }
template<typename genType> template<typename genType>
GLM_FUNC_QUALIFIER bool isIdentity( GLM_FUNC_QUALIFIER bool isIdentity
const genType& m, (
const typename genType::value_type epsilon) genType const & m,
{ typename genType::value_type const & epsilon
)
{
bool result = true; bool result = true;
for(typename genType::value_type i = typename genType::value_type(0); result && i < genType::col_size(); ++i) for(typename genType::value_type i = typename genType::value_type(0); result && i < genType::col_size(); ++i)
{ {
@ -61,13 +68,15 @@ GLM_FUNC_QUALIFIER bool isIdentity(
result = abs(m[i][j]) <= epsilon; result = abs(m[i][j]) <= epsilon;
} }
return result; return result;
} }
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized( GLM_FUNC_QUALIFIER bool isNormalized
const detail::tmat2x2<T>& m, (
const T epsilon) detail::tmat2x2<T> const & m,
{ T const & epsilon
)
{
bool result = true; bool result = true;
for(int i = 0; result && i < 2; ++i) for(int i = 0; result && i < 2; ++i)
result = isNormalized(m[i], epsilon); result = isNormalized(m[i], epsilon);
@ -79,13 +88,15 @@ GLM_FUNC_QUALIFIER bool isNormalized(
result = isNormalized(v, epsilon); result = isNormalized(v, epsilon);
} }
return result; return result;
} }
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized( GLM_FUNC_QUALIFIER bool isNormalized
const detail::tmat3x3<T>& m, (
const T epsilon) detail::tmat3x3<T> const & m,
{ T const & epsilon
)
{
bool result = true; bool result = true;
for(int i = 0; result && i < 3; ++i) for(int i = 0; result && i < 3; ++i)
result = isNormalized(m[i], epsilon); result = isNormalized(m[i], epsilon);
@ -97,13 +108,15 @@ GLM_FUNC_QUALIFIER bool isNormalized(
result = isNormalized(v, epsilon); result = isNormalized(v, epsilon);
} }
return result; return result;
} }
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized( GLM_FUNC_QUALIFIER bool isNormalized
const detail::tmat4x4<T>& m, (
const T epsilon) detail::tmat4x4<T> const & m,
{ T const & epsilon
)
{
bool result = true; bool result = true;
for(int i = 0; result && i < 4; ++i) for(int i = 0; result && i < 4; ++i)
result = isNormalized(m[i], epsilon); result = isNormalized(m[i], epsilon);
@ -115,13 +128,15 @@ GLM_FUNC_QUALIFIER bool isNormalized(
result = isNormalized(v, epsilon); result = isNormalized(v, epsilon);
} }
return result; return result;
} }
template<typename genType> template<typename genType>
GLM_FUNC_QUALIFIER bool isOrthogonal( GLM_FUNC_QUALIFIER bool isOrthogonal
const genType& m, (
const typename genType::value_type epsilon) genType const & m,
{ typename genType::value_type const & epsilon
)
{
bool result = true; bool result = true;
for(int i = 0; result && i < genType::col_size() - 1; ++i) for(int i = 0; result && i < genType::col_size() - 1; ++i)
for(int j= i + 1; result && j < genType::col_size(); ++j) for(int j= i + 1; result && j < genType::col_size(); ++j)
@ -135,6 +150,5 @@ GLM_FUNC_QUALIFIER bool isOrthogonal(
result = areOrthogonal(tmp[i], tmp[j], epsilon); result = areOrthogonal(tmp[i], tmp[j], epsilon);
} }
return result; return result;
} }
}//namespace glm }//namespace glm

View File

@ -7,15 +7,16 @@
// File : glm/gtx/mixed_product.inl // File : glm/gtx/mixed_product.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType mixedProduct( GLM_FUNC_QUALIFIER valType mixedProduct
(
detail::tvec3<valType> const & v1, detail::tvec3<valType> const & v1,
detail::tvec3<valType> const & v2, detail::tvec3<valType> const & v2,
detail::tvec3<valType> const & v3) detail::tvec3<valType> const & v3
{ )
{
return dot(cross(v1, v2), v3); return dot(cross(v1, v2), v3);
} }
}//namespace glm }//namespace glm

View File

@ -10,184 +10,111 @@
// - GLM core // - GLM core
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ #include "../core/_vectorize.hpp"
////////////////////// namespace glm
// higherMultiple {
//////////////////////
// higherMultiple
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType higherMultiple GLM_FUNC_QUALIFIER genType higherMultiple
( (
genType const & Source, genType const & Source,
genType const & Multiple genType const & Multiple
) )
{ {
genType Tmp = Source % Multiple; genType Tmp = Source % Multiple;
return Tmp ? Source + Multiple - Tmp : Source; return Tmp ? Source + Multiple - Tmp : Source;
} }
template <> template <>
GLM_FUNC_QUALIFIER detail::thalf higherMultiple GLM_FUNC_QUALIFIER detail::thalf higherMultiple
( (
detail::thalf const & SourceH, detail::thalf const & SourceH,
detail::thalf const & MultipleH detail::thalf const & MultipleH
) )
{ {
float Source = SourceH.toFloat(); float Source = SourceH.toFloat();
float Multiple = MultipleH.toFloat(); float Multiple = MultipleH.toFloat();
int Tmp = int(float(Source)) % int(Multiple); int Tmp = int(float(Source)) % int(Multiple);
return detail::thalf(Tmp ? Source + Multiple - float(Tmp) : Source); return detail::thalf(Tmp ? Source + Multiple - float(Tmp) : Source);
} }
template <> template <>
GLM_FUNC_QUALIFIER float higherMultiple GLM_FUNC_QUALIFIER float higherMultiple
( (
float const & Source, float const & Source,
float const & Multiple float const & Multiple
) )
{ {
int Tmp = int(Source) % int(Multiple); int Tmp = int(Source) % int(Multiple);
return Tmp ? Source + Multiple - float(Tmp) : Source; return Tmp ? Source + Multiple - float(Tmp) : Source;
} }
template <> template <>
GLM_FUNC_QUALIFIER double higherMultiple GLM_FUNC_QUALIFIER double higherMultiple
( (
double const & Source, double const & Source,
double const & Multiple double const & Multiple
) )
{ {
long Tmp = long(Source) % long(Multiple); long Tmp = long(Source) % long(Multiple);
return Tmp ? Source + Multiple - double(Tmp) : Source; return Tmp ? Source + Multiple - double(Tmp) : Source;
} }
template <typename T> VECTORIZE_VEC_VEC(higherMultiple)
GLM_FUNC_QUALIFIER detail::tvec2<T> higherMultiple
(
detail::tvec2<T> const & Source,
detail::tvec2<T> const & Multiple
)
{
detail::tvec2<T> Result;
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
Result[i] = higherMultiple(Source[i], Multiple[i]);
return Result;
}
template <typename T> //////////////////////
GLM_FUNC_QUALIFIER detail::tvec3<T> higherMultiple // lowerMultiple
(
detail::tvec3<T> const & Source,
detail::tvec3<T> const & Multiple
)
{
detail::tvec3<T> Result;
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
Result[i] = higherMultiple(Source[i], Multiple[i]);
return Result;
}
template <typename T> template <typename genType>
GLM_FUNC_QUALIFIER detail::tvec4<T> higherMultiple GLM_FUNC_QUALIFIER genType lowerMultiple
( (
detail::tvec4<T> const & Source,
detail::tvec4<T> const & Multiple
)
{
detail::tvec4<T> Result;
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = higherMultiple(Source[i], Multiple[i]);
return Result;
}
//////////////////////
// lowerMultiple
template <typename genType>
GLM_FUNC_QUALIFIER genType lowerMultiple
(
genType const & Source, genType const & Source,
genType const & Multiple genType const & Multiple
) )
{ {
genType Tmp = Source % Multiple; genType Tmp = Source % Multiple;
return Tmp ? Source - Tmp : Source; return Tmp ? Source - Tmp : Source;
} }
template <> template <>
GLM_FUNC_QUALIFIER detail::thalf lowerMultiple GLM_FUNC_QUALIFIER detail::thalf lowerMultiple
( (
detail::thalf const & SourceH, detail::thalf const & SourceH,
detail::thalf const & MultipleH detail::thalf const & MultipleH
) )
{ {
float Source = SourceH.toFloat(); float Source = SourceH.toFloat();
float Multiple = MultipleH.toFloat(); float Multiple = MultipleH.toFloat();
int Tmp = int(float(Source)) % int(float(Multiple)); int Tmp = int(float(Source)) % int(float(Multiple));
return detail::thalf(Tmp ? Source - float(Tmp) : Source); return detail::thalf(Tmp ? Source - float(Tmp) : Source);
} }
template <> template <>
GLM_FUNC_QUALIFIER float lowerMultiple GLM_FUNC_QUALIFIER float lowerMultiple
( (
float const & Source, float const & Source,
float const & Multiple float const & Multiple
) )
{ {
int Tmp = int(Source) % int(Multiple); int Tmp = int(Source) % int(Multiple);
return Tmp ? Source - float(Tmp) : Source; return Tmp ? Source - float(Tmp) : Source;
} }
template <> template <>
GLM_FUNC_QUALIFIER double lowerMultiple GLM_FUNC_QUALIFIER double lowerMultiple
( (
double const & Source, double const & Source,
double const & Multiple double const & Multiple
) )
{ {
long Tmp = long(Source) % long(Multiple); long Tmp = long(Source) % long(Multiple);
return Tmp ? Source - double(Tmp) : Source; return Tmp ? Source - double(Tmp) : Source;
} }
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> lowerMultiple
(
detail::tvec2<T> const & Source,
detail::tvec2<T> const & Multiple
)
{
detail::tvec2<T> Result;
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
Result[i] = lowerMultiple(Source[i], Multiple[i]);
return Result;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> lowerMultiple
(
detail::tvec3<T> const & Source,
detail::tvec3<T> const & Multiple
)
{
detail::tvec3<T> Result;
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
Result[i] = lowerMultiple(Source[i], Multiple[i]);
return Result;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> lowerMultiple
(
detail::tvec4<T> const & Source,
detail::tvec4<T> const & Multiple
)
{
detail::tvec4<T> Result;
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = lowerMultiple(Source[i], Multiple[i]);
return Result;
}
VECTORIZE_VEC_VEC(lowerMultiple)
}//namespace glm }//namespace glm

View File

@ -56,99 +56,73 @@ namespace glm
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T length2( T length2(
const T x); T const & x);
//! Returns the squared length of x.
//! From GLM_GTX_norm extension.
template <typename genType>
typename genType::value_type length2(
genType const & x);
//! Returns the squared length of x. //! Returns the squared length of x.
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T length2( T length2(
const detail::tvec2<T> & x); detail::tquat<T> const & q);
//! Returns the squared length of x.
//! From GLM_GTX_norm extension.
template <typename T>
T length2(
const detail::tvec3<T>& x);
//! Returns the squared length of x.
//! From GLM_GTX_norm extension.
template <typename T>
T length2(
const detail::tvec4<T>& x);
//! Returns the squared length of x.
//! From GLM_GTX_norm extension.
template <typename T>
T length2(
const detail::tquat<T>& q);
//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1). //! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T distance2( T distance2(
const T p0, T const & p0,
const T p1); T const & p1);
//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1). //! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename genType>
T distance2( typename genType::value_type distance2(
const detail::tvec2<T>& p0, genType const & p0,
const detail::tvec2<T>& p1); genType const & p1);
//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
//! From GLM_GTX_norm extension.
template <typename T>
T distance2(
const detail::tvec3<T>& p0,
const detail::tvec3<T>& p1);
//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
//! From GLM_GTX_norm extension.
template <typename T>
T distance2(
const detail::tvec4<T>& p0,
const detail::tvec4<T>& p1);
//! Returns the L1 norm between x and y. //! Returns the L1 norm between x and y.
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T l1Norm( T l1Norm(
const detail::tvec3<T>& x, detail::tvec3<T> const & x,
const detail::tvec3<T>& y); detail::tvec3<T> const & y);
//! Returns the L1 norm of v. //! Returns the L1 norm of v.
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T l1Norm( T l1Norm(
const detail::tvec3<T>& v); detail::tvec3<T> const & v);
//! Returns the L2 norm between x and y. //! Returns the L2 norm between x and y.
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T l2Norm( T l2Norm(
const detail::tvec3<T>& x, detail::tvec3<T> const & x,
const detail::tvec3<T>& y); detail::tvec3<T> const & y);
//! Returns the L2 norm of v. //! Returns the L2 norm of v.
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T l2Norm( T l2Norm(
const detail::tvec3<T>& x); detail::tvec3<T> const & x);
//! Returns the L norm between x and y. //! Returns the L norm between x and y.
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T lxNorm( T lxNorm(
const detail::tvec3<T>& x, detail::tvec3<T> const & x,
const detail::tvec3<T>& y, detail::tvec3<T> const & y,
unsigned int Depth); unsigned int Depth);
//! Returns the L norm of v. //! Returns the L norm of v.
//! From GLM_GTX_norm extension. //! From GLM_GTX_norm extension.
template <typename T> template <typename T>
T lxNorm( T lxNorm(
const detail::tvec3<T>& x, detail::tvec3<T> const & x,
unsigned int Depth); unsigned int Depth);
/// @} /// @}

View File

@ -7,120 +7,150 @@
// File : glm/gtx/norm.inl // File : glm/gtx/norm.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER T length2(
const T x)
{ {
template <typename T>
GLM_FUNC_QUALIFIER T length2
(
T const & x
)
{
return x * x; return x * x;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length2( GLM_FUNC_QUALIFIER T length2
const detail::tvec2<T>& x) (
{ detail::tvec2<T> const & x
)
{
return dot(x, x); return dot(x, x);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length2( GLM_FUNC_QUALIFIER T length2
const detail::tvec3<T>& x) (
{ detail::tvec3<T> const & x
)
{
return dot(x, x); return dot(x, x);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length2( GLM_FUNC_QUALIFIER T length2
const detail::tvec4<T>& x) (
{ detail::tvec4<T> const & x
)
{
return dot(x, x); return dot(x, x);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length2( GLM_FUNC_QUALIFIER T length2
const detail::tquat<T>& q) (
{ detail::tquat<T> const & q
)
{
return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w; return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
} }
template <typename T> template <typename T>
T distance2( GLM_FUNC_QUALIFIER T distance2
const T p0, (
const T p1) T const & p0,
{ T const & p1
)
{
return length2(p1 - p0); return length2(p1 - p0);
} }
template <typename T> template <typename T>
T distance2( GLM_FUNC_QUALIFIER T distance2
const detail::tvec2<T>& p0, (
const detail::tvec2<T>& p1) detail::tvec2<T> const & p0,
{ detail::tvec2<T> const & p1
)
{
return length2(p1 - p0); return length2(p1 - p0);
} }
template <typename T> template <typename T>
T distance2( GLM_FUNC_QUALIFIER T distance2
const detail::tvec3<T>& p0, (
const detail::tvec3<T>& p1) detail::tvec3<T> const & p0,
{ detail::tvec3<T> const & p1
)
{
return length2(p1 - p0); return length2(p1 - p0);
} }
template <typename T> template <typename T>
T distance2( GLM_FUNC_QUALIFIER T distance2
const detail::tvec4<T>& p0, (
const detail::tvec4<T>& p1) detail::tvec4<T> const & p0,
{ detail::tvec4<T> const & p1
)
{
return length2(p1 - p0); return length2(p1 - p0);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T l1Norm( GLM_FUNC_QUALIFIER T l1Norm
const detail::tvec3<T>& a, (
const detail::tvec3<T>& b) detail::tvec3<T> const & a,
{ detail::tvec3<T> const & b
)
{
return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z); return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T l1Norm( GLM_FUNC_QUALIFIER T l1Norm
const detail::tvec3<T>& v) (
{ detail::tvec3<T> const & v
)
{
return abs(v.x) + abs(v.y) + abs(v.z); return abs(v.x) + abs(v.y) + abs(v.z);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T l2Norm( GLM_FUNC_QUALIFIER T l2Norm
const detail::tvec3<T>& a, (
const detail::tvec3<T>& b) detail::tvec3<T> const & a,
{ detail::tvec3<T> const & b
)
{
return length(b - a); return length(b - a);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T l2Norm( GLM_FUNC_QUALIFIER T l2Norm
const detail::tvec3<T>& v) (
{ detail::tvec3<T> const & v
)
{
return length(v); return length(v);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T lxNorm( GLM_FUNC_QUALIFIER T lxNorm
const detail::tvec3<T>& x, (
const detail::tvec3<T>& y, detail::tvec3<T> const & x,
unsigned int Depth) detail::tvec3<T> const & y,
{ unsigned int Depth
)
{
return pow(pow(y.x - x.x, T(Depth)) + pow(y.y - x.y, T(Depth)) + pow(y.z - x.z, T(Depth)), T(1) / T(Depth)); return pow(pow(y.x - x.x, T(Depth)) + pow(y.y - x.y, T(Depth)) + pow(y.z - x.z, T(Depth)), T(1) / T(Depth));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T lxNorm( GLM_FUNC_QUALIFIER T lxNorm
const detail::tvec3<T>& v, (
unsigned int Depth) detail::tvec3<T> const & v,
{ unsigned int Depth
)
{
return pow(pow(v.x, T(Depth)) + pow(v.y, T(Depth)) + pow(v.z, T(Depth)), T(1) / T(Depth)); return pow(pow(v.x, T(Depth)) + pow(v.y, T(Depth)) + pow(v.z, T(Depth)), T(1) / T(Depth));
} }
}//namespace glm }//namespace glm

View File

@ -7,17 +7,16 @@
// File : glm/gtx/normal.inl // File : glm/gtx/normal.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> triangleNormal GLM_FUNC_QUALIFIER detail::tvec3<T> triangleNormal
( (
detail::tvec3<T> const & p1, detail::tvec3<T> const & p1,
detail::tvec3<T> const & p2, detail::tvec3<T> const & p2,
detail::tvec3<T> const & p3 detail::tvec3<T> const & p3
) )
{ {
return normalize(cross(p1 - p2, p1 - p3)); return normalize(cross(p1 - p2, p1 - p3));
} }
}//namespace glm }//namespace glm

View File

@ -7,110 +7,109 @@
// File : glm/gtx/normalize_dot.inl // File : glm/gtx/normalize_dot.inl
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType normalizeDot GLM_FUNC_QUALIFIER genType normalizeDot
( (
genType const & x, genType const & x,
genType const & y genType const & y
) )
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
glm::inversesqrt(glm::dot(x, x) * glm::inversesqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType normalizeDot GLM_FUNC_QUALIFIER valType normalizeDot
( (
detail::tvec2<valType> const & x, detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y detail::tvec2<valType> const & y
) )
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
glm::inversesqrt(glm::dot(x, x) * glm::inversesqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType normalizeDot GLM_FUNC_QUALIFIER valType normalizeDot
( (
detail::tvec3<valType> const & x, detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y detail::tvec3<valType> const & y
) )
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
glm::inversesqrt(glm::dot(x, x) * glm::inversesqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType normalizeDot GLM_FUNC_QUALIFIER valType normalizeDot
( (
detail::tvec4<valType> const & x, detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y detail::tvec4<valType> const & y
) )
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
glm::inversesqrt(glm::dot(x, x) * glm::inversesqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType fastNormalizeDot GLM_FUNC_QUALIFIER genType fastNormalizeDot
( (
genType const & x, genType const & x,
genType const & y genType const & y
) )
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
fastInverseSqrt(glm::dot(x, x) * fastInverseSqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType fastNormalizeDot GLM_FUNC_QUALIFIER valType fastNormalizeDot
( (
detail::tvec2<valType> const & x, detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y detail::tvec2<valType> const & y
) )
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
fastInverseSqrt(glm::dot(x, x) * fastInverseSqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType fastNormalizeDot GLM_FUNC_QUALIFIER valType fastNormalizeDot
( (
detail::tvec3<valType> const & x, detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y detail::tvec3<valType> const & y
) )
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
fastInverseSqrt(glm::dot(x, x) * fastInverseSqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType fastNormalizeDot GLM_FUNC_QUALIFIER valType fastNormalizeDot
( (
detail::tvec4<valType> const & x, detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y detail::tvec4<valType> const & y
) )
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
fastInverseSqrt(glm::dot(x, x) * fastInverseSqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
}//namespace glm }//namespace glm

View File

@ -7,53 +7,52 @@
// File : glm/gtx/optimum_pow.inl // File : glm/gtx/optimum_pow.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER genType pow2(const genType& x)
{ {
template <typename genType>
GLM_FUNC_QUALIFIER genType pow2(const genType& x)
{
return x * x; return x * x;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType pow3(const genType& x) GLM_FUNC_QUALIFIER genType pow3(const genType& x)
{ {
return x * x * x; return x * x * x;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType pow4(const genType& x) GLM_FUNC_QUALIFIER genType pow4(const genType& x)
{ {
return x * x * x * x; return x * x * x * x;
} }
GLM_FUNC_QUALIFIER bool powOfTwo(int x) GLM_FUNC_QUALIFIER bool powOfTwo(int x)
{ {
return !(x & (x - 1)); return !(x & (x - 1));
} }
GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x) GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x)
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
powOfTwo(x.x), powOfTwo(x.x),
powOfTwo(x.y)); powOfTwo(x.y));
} }
GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x) GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x)
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
powOfTwo(x.x), powOfTwo(x.x),
powOfTwo(x.y), powOfTwo(x.y),
powOfTwo(x.z)); powOfTwo(x.z));
} }
GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x) GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x)
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
powOfTwo(x.x), powOfTwo(x.x),
powOfTwo(x.y), powOfTwo(x.y),
powOfTwo(x.z), powOfTwo(x.z),
powOfTwo(x.w)); powOfTwo(x.w));
} }
}//namespace glm }//namespace glm

View File

@ -7,14 +7,14 @@
// File : glm/gtx/orthonormalize.inl // File : glm/gtx/orthonormalize.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> orthonormalize
(
const detail::tmat3x3<T>& m
)
{ {
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> orthonormalize
(
const detail::tmat3x3<T>& m
)
{
detail::tmat3x3<T> r = m; detail::tmat3x3<T> r = m;
r[0] = normalize(r[0]); r[0] = normalize(r[0]);
@ -29,16 +29,15 @@ GLM_FUNC_QUALIFIER detail::tmat3x3<T> orthonormalize
r[2] = normalize(r[2]); r[2] = normalize(r[2]);
return r; return r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> orthonormalize GLM_FUNC_QUALIFIER detail::tvec3<T> orthonormalize
( (
const detail::tvec3<T>& x, const detail::tvec3<T>& x,
const detail::tvec3<T>& y const detail::tvec3<T>& y
) )
{ {
return normalize(x - y * dot(y, x)); return normalize(x - y * dot(y, x));
} }
}//namespace glm }//namespace glm

View File

@ -54,24 +54,10 @@ namespace glm
//! Projects x a perpendicular axis of Normal. //! Projects x a perpendicular axis of Normal.
//! From GLM_GTX_perpendicular extension. //! From GLM_GTX_perpendicular extension.
template <typename T> template <typename vecType>
detail::tvec2<T> perp( vecType perp(
detail::tvec2<T> const & x, vecType const & x,
detail::tvec2<T> const & Normal); vecType const & Normal);
//! Projects x a perpendicular axis of Normal.
//! From GLM_GTX_perpendicular extension.
template <typename T>
detail::tvec3<T> perp(
detail::tvec3<T> const & x,
detail::tvec3<T> const & Normal);
//! Projects x a perpendicular axis of Normal.
//! From GLM_GTX_perpendicular extension.
template <typename T>
detail::tvec4<T> perp(
detail::tvec4<T> const & x,
detail::tvec4<T> const & Normal);
/// @} /// @}
}//namespace glm }//namespace glm

View File

@ -7,30 +7,15 @@
// File : glm/gtx/perpendicular.inl // File : glm/gtx/perpendicular.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> perp(
detail::tvec2<T> const & x,
detail::tvec2<T> const & Normal)
{ {
template <typename vecType>
GLM_FUNC_QUALIFIER vecType perp
(
vecType const & x,
vecType const & Normal
)
{
return x - proj(x, Normal); return x - proj(x, Normal);
} }
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> perp(
detail::tvec3<T> const & x,
detail::tvec3<T> const & Normal)
{
return x - proj(x, Normal);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> perp(
detail::tvec4<T> const & x,
detail::tvec4<T> const & Normal)
{
return x - proj(x, Normal);
}
}//namespace glm }//namespace glm

View File

@ -53,12 +53,14 @@ namespace glm
//! Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude. //! Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude.
//! From GLM_GTX_polar_coordinates extension. //! From GLM_GTX_polar_coordinates extension.
template <typename T> template <typename T>
detail::tvec3<T> polar(const detail::tvec3<T>& euclidean); detail::tvec3<T> polar(
detail::tvec3<T> const & euclidean);
//! Convert Polar to Euclidean coordinates. //! Convert Polar to Euclidean coordinates.
//! From GLM_GTX_polar_coordinates extension. //! From GLM_GTX_polar_coordinates extension.
template <typename T> template <typename T>
detail::tvec3<T> euclidean(const detail::tvec3<T>& polar); detail::tvec3<T> euclidean(
detail::tvec3<T> const & polar);
/// @} /// @}
}//namespace glm }//namespace glm

View File

@ -10,8 +10,10 @@
namespace glm namespace glm
{ {
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> polar( GLM_FUNC_QUALIFIER detail::tvec3<T> polar
const detail::tvec3<T>& euclidean) (
detail::tvec3<T> const & euclidean
)
{ {
T length = length(euclidean); T length = length(euclidean);
detail::tvec3<T> tmp = euclidean / length; detail::tvec3<T> tmp = euclidean / length;
@ -24,8 +26,10 @@ namespace glm
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> euclidean( GLM_FUNC_QUALIFIER detail::tvec3<T> euclidean
const detail::tvec3<T>& polar) (
detail::tvec3<T> const & polar
)
{ {
T latitude = radians(polar.x); T latitude = radians(polar.x);
T longitude = radians(polar.y); T longitude = radians(polar.y);

View File

@ -52,24 +52,10 @@ namespace glm
//! Projects x on Normal. //! Projects x on Normal.
//! From GLM_GTX_projection extension. //! From GLM_GTX_projection extension.
template <typename T> template <typename vecType>
detail::tvec2<T> proj( vecType proj(
detail::tvec2<T> const & x, vecType const & x,
detail::tvec2<T> const & Normal); vecType const & Normal);
//! Projects x on Normal.
//! From GLM_GTX_projection extension.
template <typename T>
detail::tvec3<T> proj(
detail::tvec3<T> const & x,
detail::tvec3<T> const & Normal);
//! Projects x on Normal.
//! From GLM_GTX_projection extension.
template <typename T>
detail::tvec4<T> proj(
detail::tvec4<T> const & x,
detail::tvec4<T> const & Normal);
/// @} /// @}
}//namespace glm }//namespace glm

View File

@ -7,30 +7,15 @@
// File : glm/gtx/projection.inl // File : glm/gtx/projection.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> proj(
detail::tvec2<T> const & x,
detail::tvec2<T> const & Normal)
{ {
template <typename vecType>
GLM_FUNC_QUALIFIER vecType proj
(
vecType const & x,
vecType const & Normal
)
{
return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal; return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal;
} }
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> proj(
detail::tvec3<T> const & x,
detail::tvec3<T> const & Normal)
{
return dot(x, Normal) / glm::dot(Normal, Normal) * Normal;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> proj(
detail::tvec4<T> const & x,
detail::tvec4<T> const & Normal)
{
return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal;
}
}//namespace glm }//namespace glm

View File

@ -9,71 +9,71 @@
#include <limits> #include <limits>
namespace glm{ namespace glm
{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> cross GLM_FUNC_QUALIFIER detail::tvec3<valType> cross
( (
detail::tvec3<valType> const & v, detail::tvec3<valType> const & v,
detail::tquat<valType> const & q detail::tquat<valType> const & q
) )
{ {
return inverse(q) * v; return inverse(q) * v;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> cross GLM_FUNC_QUALIFIER detail::tvec3<valType> cross
( (
detail::tquat<valType> const & q, detail::tquat<valType> const & q,
detail::tvec3<valType> const & v detail::tvec3<valType> const & v
) )
{ {
return q * v; return q * v;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tquat<T> squad GLM_FUNC_QUALIFIER detail::tquat<T> squad
( (
detail::tquat<T> const & q1, detail::tquat<T> const & q1,
detail::tquat<T> const & q2, detail::tquat<T> const & q2,
detail::tquat<T> const & s1, detail::tquat<T> const & s1,
detail::tquat<T> const & s2, detail::tquat<T> const & s2,
T const & h) T const & h)
{ {
return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * h (T(1) - h)); return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * h (T(1) - h));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tquat<T> intermediate GLM_FUNC_QUALIFIER detail::tquat<T> intermediate
( (
detail::tquat<T> const & prev, detail::tquat<T> const & prev,
detail::tquat<T> const & curr, detail::tquat<T> const & curr,
detail::tquat<T> const & next detail::tquat<T> const & next
) )
{ {
detail::tquat<T> invQuat = inverse(curr); detail::tquat<T> invQuat = inverse(curr);
return ext((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr; return ext((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tquat<T> exp GLM_FUNC_QUALIFIER detail::tquat<T> exp
( (
detail::tquat<T> const & q, detail::tquat<T> const & q,
T const & exponent T const & exponent
) )
{ {
detail::tvec3<T> u(q.x, q.y, q.z); detail::tvec3<T> u(q.x, q.y, q.z);
float a = glm::length(u); float a = glm::length(u);
detail::tvec3<T> v(u / a); detail::tvec3<T> v(u / a);
return detail::tquat<T>(cos(a), sin(a) * v); return detail::tquat<T>(cos(a), sin(a) * v);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tquat<T> log GLM_FUNC_QUALIFIER detail::tquat<T> log
( (
detail::tquat<T> const & q detail::tquat<T> const & q
) )
{ {
if((q.x == T(0)) && (q.y == T(0)) && (q.z == T(0))) if((q.x == T(0)) && (q.y == T(0)) && (q.z == T(0)))
{ {
if(q.w > T(0)) if(q.w > T(0))
@ -90,15 +90,15 @@ GLM_FUNC_QUALIFIER detail::tquat<T> log
T t = atan(Vec3Len, T(q.w)) / Vec3Len; T t = atan(Vec3Len, T(q.w)) / Vec3Len;
return detail::tquat<T>(t * q.x, t * q.y, t * q.z, log(QuatLen)); return detail::tquat<T>(t * q.x, t * q.y, t * q.z, log(QuatLen));
} }
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tquat<T> pow GLM_FUNC_QUALIFIER detail::tquat<T> pow
( (
detail::tquat<T> const & x, detail::tquat<T> const & x,
T const & y T const & y
) )
{ {
if(abs(x.w) > T(0.9999)) if(abs(x.w) > T(0.9999))
return x; return x;
float Angle = acos(y); float Angle = acos(y);
@ -109,79 +109,79 @@ GLM_FUNC_QUALIFIER detail::tquat<T> pow
x.x * Div, x.x * Div,
x.y * Div, x.y * Div,
x.z * Div); x.z * Div);
} }
//template <typename T> //template <typename T>
//GLM_FUNC_QUALIFIER detail::tquat<T> sqrt //GLM_FUNC_QUALIFIER detail::tquat<T> sqrt
//( //(
// detail::tquat<T> const & q // detail::tquat<T> const & q
//) //)
//{ //{
// T q0 = T(1) - dot(q, q); // T q0 = T(1) - dot(q, q);
// return T(2) * (T(1) + q0) * q; // return T(2) * (T(1) + q0) * q;
//} //}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rotate GLM_FUNC_QUALIFIER detail::tvec3<T> rotate
( (
detail::tquat<T> const & q, detail::tquat<T> const & q,
detail::tvec3<T> const & v detail::tvec3<T> const & v
) )
{ {
return q * v; return q * v;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> rotate GLM_FUNC_QUALIFIER detail::tvec4<T> rotate
( (
detail::tquat<T> const & q, detail::tquat<T> const & q,
detail::tvec4<T> const & v detail::tvec4<T> const & v
) )
{ {
return q * v; return q * v;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T angle GLM_FUNC_QUALIFIER T angle
( (
detail::tquat<T> const & x detail::tquat<T> const & x
) )
{ {
return glm::degrees(acos(x.w) * T(2)); return glm::degrees(acos(x.w) * T(2));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> axis GLM_FUNC_QUALIFIER detail::tvec3<T> axis
( (
detail::tquat<T> const & x detail::tquat<T> const & x
) )
{ {
T tmp1 = T(1) - x.w * x.w; T tmp1 = T(1) - x.w * x.w;
if(tmp1 <= T(0)) if(tmp1 <= T(0))
return detail::tvec3<T>(0, 0, 1); return detail::tvec3<T>(0, 0, 1);
T tmp2 = T(1) / sqrt(tmp1); T tmp2 = T(1) / sqrt(tmp1);
return detail::tvec3<T>(x.x * tmp2, x.y * tmp2, x.z * tmp2); return detail::tvec3<T>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
( (
valType const & angle, valType const & angle,
valType const & x, valType const & x,
valType const & y, valType const & y,
valType const & z valType const & z
) )
{ {
return angleAxis(angle, detail::tvec3<valType>(x, y, z)); return angleAxis(angle, detail::tvec3<valType>(x, y, z));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
( (
valType const & angle, valType const & angle,
detail::tvec3<valType> const & v detail::tvec3<valType> const & v
) )
{ {
detail::tquat<valType> result; detail::tquat<valType> result;
valType a = glm::radians(angle); valType a = glm::radians(angle);
@ -192,65 +192,65 @@ GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
result.y = v.y * s; result.y = v.y * s;
result.z = v.z * s; result.z = v.z * s;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T extractRealComponent GLM_FUNC_QUALIFIER T extractRealComponent
( (
detail::tquat<T> const & q detail::tquat<T> const & q
) )
{ {
T w = T(1.0) - q.x * q.x - q.y * q.y - q.z * q.z; T w = T(1.0) - q.x * q.x - q.y * q.y - q.z * q.z;
if(w < T(0)) if(w < T(0))
return T(0); return T(0);
else else
return -sqrt(w); return -sqrt(w);
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType roll GLM_FUNC_QUALIFIER valType roll
( (
detail::tquat<valType> const & q detail::tquat<valType> const & q
) )
{ {
return glm::degrees(atan2(valType(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z)); return glm::degrees(atan2(valType(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType pitch GLM_FUNC_QUALIFIER valType pitch
( (
detail::tquat<valType> const & q detail::tquat<valType> const & q
) )
{ {
return glm::degrees(atan2(valType(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z)); return glm::degrees(atan2(valType(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType yaw GLM_FUNC_QUALIFIER valType yaw
( (
detail::tquat<valType> const & q detail::tquat<valType> const & q
) )
{ {
return glm::degrees(asin(valType(-2) * (q.x * q.z - q.w * q.y))); return glm::degrees(asin(valType(-2) * (q.x * q.z - q.w * q.y)));
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> eularAngles GLM_FUNC_QUALIFIER detail::tvec3<valType> eularAngles
( (
detail::tquat<valType> const & x detail::tquat<valType> const & x
) )
{ {
return detail::tvec3<valType>(pitch(x), yaw(x), roll(x)); return detail::tvec3<valType>(pitch(x), yaw(x), roll(x));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tquat<T> shortMix GLM_FUNC_QUALIFIER detail::tquat<T> shortMix
( (
detail::tquat<T> const & x, detail::tquat<T> const & x,
detail::tquat<T> const & y, detail::tquat<T> const & y,
T const & a T const & a
) )
{ {
if(a <= typename detail::tquat<T>::value_type(0)) return x; if(a <= typename detail::tquat<T>::value_type(0)) return x;
if(a >= typename detail::tquat<T>::value_type(1)) return y; if(a >= typename detail::tquat<T>::value_type(1)) return y;
@ -283,17 +283,16 @@ GLM_FUNC_QUALIFIER detail::tquat<T> shortMix
k0 * x.x + k1 * y2.x, k0 * x.x + k1 * y2.x,
k0 * x.y + k1 * y2.y, k0 * x.y + k1 * y2.y,
k0 * x.z + k1 * y2.z); k0 * x.z + k1 * y2.z);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tquat<T> fastMix GLM_FUNC_QUALIFIER detail::tquat<T> fastMix
( (
detail::tquat<T> const & x, detail::tquat<T> const & x,
detail::tquat<T> const & y, detail::tquat<T> const & y,
T const & a T const & a
) )
{ {
return glm::normalize(x * (T(1) - a) + (y * a)); return glm::normalize(x * (T(1) - a) + (y * a));
} }
}//namespace glm }//namespace glm

View File

@ -2,588 +2,181 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-10-09 // Created : 2008-10-09
// Updated : 2008-10-09 // Updated : 2011-10-14
// Licence : This source is under MIT License // Licence : This source is under MIT License
// File : glm/gtx/reciprocal.inl // File : glm/gtx/reciprocal.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ #include "../core/_vectorize.hpp"
// sec namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER genType sec
(
genType const & angle
)
{ {
// sec
template <typename genType>
GLM_FUNC_QUALIFIER genType sec
(
genType const & angle
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sec' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sec' only accept floating-point values");
return genType(1) / glm::cos(angle); return genType(1) / glm::cos(angle);
} }
template <typename valType> VECTORIZE_VEC(sec)
GLM_FUNC_QUALIFIER detail::tvec2<valType> sec
(
detail::tvec2<valType> const & angle
)
{
return detail::tvec2<valType>(
sec(angle.x),
sec(angle.y));
}
template <typename valType> // csc
GLM_FUNC_QUALIFIER detail::tvec3<valType> sec template <typename genType>
( GLM_FUNC_QUALIFIER genType csc
detail::tvec3<valType> const & angle (
)
{
return detail::tvec3<valType>(
sec(angle.x),
sec(angle.y),
sec(angle.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> sec
(
detail::tvec4<valType> const & angle
)
{
return detail::tvec4<valType>(
sec(angle.x),
sec(angle.y),
sec(angle.z),
sec(angle.w));
}
// csc
template <typename genType>
GLM_FUNC_QUALIFIER genType csc
(
genType const & angle genType const & angle
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csc' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csc' only accept floating-point values");
return genType(1) / glm::sin(angle); return genType(1) / glm::sin(angle);
} }
template <typename valType> VECTORIZE_VEC(csc)
GLM_FUNC_QUALIFIER detail::tvec2<valType> csc
(
detail::tvec2<valType> const & angle
)
{
return detail::tvec2<valType>(
csc(angle.x),
csc(angle.y));
}
template <typename valType> // cot
GLM_FUNC_QUALIFIER detail::tvec3<valType> csc template <typename genType>
( GLM_FUNC_QUALIFIER genType cot
detail::tvec3<valType> const & angle (
)
{
return detail::tvec3<valType>(
csc(angle.x),
csc(angle.y),
csc(angle.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> csc
(
detail::tvec4<valType> const & angle
)
{
return detail::tvec4<valType>(
csc(angle.x),
csc(angle.y),
csc(angle.z),
csc(angle.w));
}
// cot
template <typename genType>
GLM_FUNC_QUALIFIER genType cot
(
genType const & angle genType const & angle
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cot' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cot' only accept floating-point values");
return genType(1) / glm::tan(angle); return genType(1) / glm::tan(angle);
} }
template <typename valType> VECTORIZE_VEC(cot)
GLM_FUNC_QUALIFIER detail::tvec2<valType> cot
(
detail::tvec2<valType> const & angle
)
{
return detail::tvec2<valType>(
cot(angle.x),
cot(angle.y));
}
template <typename valType> // asec
GLM_FUNC_QUALIFIER detail::tvec3<valType> cot template <typename genType>
( GLM_FUNC_QUALIFIER genType asec
detail::tvec3<valType> const & angle (
)
{
return detail::tvec3<valType>(
cot(angle.x),
cot(angle.y),
cot(angle.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> cot
(
detail::tvec4<valType> const & angle
)
{
return detail::tvec4<valType>(
cot(angle.x),
cot(angle.y),
cot(angle.z),
cot(angle.w));
}
// asec
template <typename genType>
GLM_FUNC_QUALIFIER genType asec
(
genType const & x genType const & x
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asec' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asec' only accept floating-point values");
return acos(genType(1) / x); return acos(genType(1) / x);
} }
template <typename valType> VECTORIZE_VEC(asec)
GLM_FUNC_QUALIFIER detail::tvec2<valType> asec
(
detail::tvec2<valType> const & x
)
{
return detail::tvec2<valType>(
asec(x.x),
asec(x.y));
}
template <typename valType> // acsc
GLM_FUNC_QUALIFIER detail::tvec3<valType> asec template <typename genType>
( GLM_FUNC_QUALIFIER genType acsc
detail::tvec3<valType> const & x (
)
{
return detail::tvec3<valType>(
asec(x.x),
asec(x.y),
asec(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> asec
(
detail::tvec4<valType> const & x
)
{
return detail::tvec4<valType>(
asec(x.x),
asec(x.y),
asec(x.z),
asec(x.w));
}
// acsc
template <typename genType>
GLM_FUNC_QUALIFIER genType acsc
(
genType const & x genType const & x
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsc' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsc' only accept floating-point values");
return asin(genType(1) / x); return asin(genType(1) / x);
} }
template <typename valType> VECTORIZE_VEC(acsc)
GLM_FUNC_QUALIFIER detail::tvec2<valType> acsc
(
detail::tvec2<valType> const & x
)
{
return detail::tvec2<valType>(
acsc(x.x),
acsc(x.y));
}
template <typename valType> // acot
GLM_FUNC_QUALIFIER detail::tvec3<valType> acsc template <typename genType>
( GLM_FUNC_QUALIFIER genType acot
detail::tvec3<valType> const & x (
)
{
return detail::tvec3<valType>(
acsc(x.x),
acsc(x.y),
acsc(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> acsc
(
detail::tvec4<valType> const & x
)
{
return detail::tvec4<valType>(
acsc(x.x),
acsc(x.y),
acsc(x.z),
acsc(x.w));
}
// acot
template <typename genType>
GLM_FUNC_QUALIFIER genType acot
(
genType const & x genType const & x
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acot' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acot' only accept floating-point values");
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0); genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
return pi_over_2 - atan(x); return pi_over_2 - atan(x);
} }
template <typename valType> VECTORIZE_VEC(acot)
GLM_FUNC_QUALIFIER detail::tvec2<valType> acot
(
detail::tvec2<valType> const & x
)
{
return detail::tvec2<valType>(
acot(x.x),
acot(x.y));
}
template <typename valType> // sech
GLM_FUNC_QUALIFIER detail::tvec3<valType> acot template <typename genType>
( GLM_FUNC_QUALIFIER genType sech
detail::tvec3<valType> const & x (
)
{
return detail::tvec3<valType>(
acot(x.x),
acot(x.y),
acot(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> acot
(
detail::tvec4<valType> const & x
)
{
return detail::tvec4<valType>(
acot(x.x),
acot(x.y),
acot(x.z),
acot(x.w));
}
// sech
template <typename genType>
GLM_FUNC_QUALIFIER genType sech
(
genType const & angle genType const & angle
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sech' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sech' only accept floating-point values");
return genType(1) / glm::cosh(angle); return genType(1) / glm::cosh(angle);
} }
template <typename valType> VECTORIZE_VEC(sech)
GLM_FUNC_QUALIFIER detail::tvec2<valType> sech
(
detail::tvec2<valType> const & angle
)
{
return detail::tvec2<valType>(
sech(angle.x),
sech(angle.y));
}
template <typename valType> // csch
GLM_FUNC_QUALIFIER detail::tvec3<valType> sech template <typename genType>
( GLM_FUNC_QUALIFIER genType csch
detail::tvec3<valType> const & angle (
)
{
return detail::tvec3<valType>(
sech(angle.x),
sech(angle.y),
sech(angle.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> sech
(
detail::tvec4<valType> const & angle
)
{
return detail::tvec4<valType>(
sech(angle.x),
sech(angle.y),
sech(angle.z),
sech(angle.w));
}
// csch
template <typename genType>
GLM_FUNC_QUALIFIER genType csch
(
genType const & angle genType const & angle
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csch' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csch' only accept floating-point values");
return genType(1) / glm::sinh(angle); return genType(1) / glm::sinh(angle);
} }
template <typename valType> VECTORIZE_VEC(csch)
GLM_FUNC_QUALIFIER detail::tvec2<valType> csch
(
detail::tvec2<valType> const & angle
)
{
return detail::tvec2<valType>(
csch(angle.x),
csch(angle.y));
}
template <typename valType> // coth
GLM_FUNC_QUALIFIER detail::tvec3<valType> csch template <typename genType>
( GLM_FUNC_QUALIFIER genType coth
detail::tvec3<valType> const & angle (
)
{
return detail::tvec3<valType>(
csch(angle.x),
csch(angle.y),
csch(angle.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> csch
(
detail::tvec4<valType> const & angle
)
{
return detail::tvec4<valType>(
csch(angle.x),
csch(angle.y),
csch(angle.z),
csch(angle.w));
}
// coth
template <typename genType>
GLM_FUNC_QUALIFIER genType coth
(
genType const & angle genType const & angle
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'coth' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'coth' only accept floating-point values");
return glm::cosh(angle) / glm::sinh(angle); return glm::cosh(angle) / glm::sinh(angle);
} }
template <typename valType> VECTORIZE_VEC(coth)
GLM_FUNC_QUALIFIER detail::tvec2<valType> coth
(
detail::tvec2<valType> const & angle
)
{
return detail::tvec2<valType>(
coth(angle.x),
coth(angle.y));
}
template <typename valType> // asech
GLM_FUNC_QUALIFIER detail::tvec3<valType> coth template <typename genType>
( GLM_FUNC_QUALIFIER genType asech
detail::tvec3<valType> const & angle (
)
{
return detail::tvec3<valType>(
coth(angle.x),
coth(angle.y),
coth(angle.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> coth
(
detail::tvec4<valType> const & angle
)
{
return detail::tvec4<valType>(
coth(angle.x),
coth(angle.y),
coth(angle.z),
coth(angle.w));
}
// asech
template <typename genType>
GLM_FUNC_QUALIFIER genType asech
(
genType const & x genType const & x
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asech' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asech' only accept floating-point values");
return acosh(genType(1) / x); return acosh(genType(1) / x);
} }
template <typename valType> VECTORIZE_VEC(asech)
GLM_FUNC_QUALIFIER detail::tvec2<valType> asech
(
detail::tvec2<valType> const & x
)
{
return detail::tvec2<valType>(
asech(x.x),
asech(x.y));
}
template <typename valType> // acsch
GLM_FUNC_QUALIFIER detail::tvec3<valType> asech template <typename genType>
( GLM_FUNC_QUALIFIER genType acsch
detail::tvec3<valType> const & x (
)
{
return detail::tvec3<valType>(
asech(x.x),
asech(x.y),
asech(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> asech
(
detail::tvec4<valType> const & x
)
{
return detail::tvec4<valType>(
asech(x.x),
asech(x.y),
asech(x.z),
asech(x.w));
}
// acsch
template <typename genType>
GLM_FUNC_QUALIFIER genType acsch
(
genType const & x genType const & x
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsch' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsch' only accept floating-point values");
return asinh(genType(1) / x); return asinh(genType(1) / x);
} }
template <typename valType> VECTORIZE_VEC(acsch)
GLM_FUNC_QUALIFIER detail::tvec2<valType> acsch
(
detail::tvec2<valType> const & x
)
{
return detail::tvec2<valType>(
acsch(x.x),
acsch(x.y));
}
template <typename valType> // acoth
GLM_FUNC_QUALIFIER detail::tvec3<valType> acsch template <typename genType>
( GLM_FUNC_QUALIFIER genType acoth
detail::tvec3<valType> const & x (
)
{
return detail::tvec3<valType>(
acsch(x.x),
acsch(x.y),
acsch(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> acsch
(
detail::tvec4<valType> const & x
)
{
return detail::tvec4<valType>(
acsch(x.x),
acsch(x.y),
acsch(x.z),
acsch(x.w));
}
// acoth
template <typename genType>
GLM_FUNC_QUALIFIER genType acoth
(
genType const & x genType const & x
) )
{ {
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acoth' only accept floating-point values"); GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acoth' only accept floating-point values");
return atanh(genType(1) / x); return atanh(genType(1) / x);
} }
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> acoth
(
detail::tvec2<valType> const & x
)
{
return detail::tvec2<valType>(
acoth(x.x),
acoth(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> acoth
(
detail::tvec3<valType> const & x
)
{
return detail::tvec3<valType>(
acoth(x.x),
acoth(x.y),
acoth(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> acoth
(
detail::tvec4<valType> const & x
)
{
return detail::tvec4<valType>(
acoth(x.x),
acoth(x.y),
acoth(x.z),
acoth(x.w));
}
VECTORIZE_VEC(acoth)
}//namespace glm }//namespace glm

View File

@ -7,139 +7,158 @@
// File : glm/gtx/rotate_vector.inl // File : glm/gtx/rotate_vector.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> rotate(
detail::tvec2<T> const & v,
T const & angle)
{ {
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> rotate
(
detail::tvec2<T> const & v,
T const & angle
)
{
detail::tvec2<T> Result; detail::tvec2<T> Result;
const T Cos = cos(radians(angle)); T const Cos = cos(radians(angle));
const T Sin = sin(radians(angle)); T const Sin = sin(radians(angle));
Result.x = v.x * Cos - v.y * Sin; Result.x = v.x * Cos - v.y * Sin;
Result.y = v.x * Sin + v.y * Cos; Result.y = v.x * Sin + v.y * Cos;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rotate( GLM_FUNC_QUALIFIER detail::tvec3<T> rotate
const detail::tvec3<T> & v, (
detail::tvec3<T> const & v,
T const & angle, T const & angle,
const detail::tvec3<T> & normal) detail::tvec3<T> const & normal
{ )
{
return detail::tmat3x3<T>(glm::rotate(angle, normal)) * v; return detail::tmat3x3<T>(glm::rotate(angle, normal)) * v;
} }
/* /*
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateGTX( GLM_FUNC_QUALIFIER detail::tvec3<T> rotateGTX(
const detail::tvec3<T>& x, const detail::tvec3<T>& x,
T angle, T angle,
const detail::tvec3<T>& normal) const detail::tvec3<T>& normal)
{ {
const T Cos = cos(radians(angle)); const T Cos = cos(radians(angle));
const T Sin = sin(radians(angle)); const T Sin = sin(radians(angle));
return x * Cos + ((x * normal) * (T(1) - Cos)) * normal + cross(x, normal) * Sin; return x * Cos + ((x * normal) * (T(1) - Cos)) * normal + cross(x, normal) * Sin;
} }
*/ */
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> rotate( GLM_FUNC_QUALIFIER detail::tvec4<T> rotate
(
detail::tvec4<T> const & v, detail::tvec4<T> const & v,
T const & angle, T const & angle,
detail::tvec3<T> const & normal) detail::tvec3<T> const & normal
{ )
{
return rotate(angle, normal) * v; return rotate(angle, normal) * v;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateX( GLM_FUNC_QUALIFIER detail::tvec3<T> rotateX
(
detail::tvec3<T> const & v, detail::tvec3<T> const & v,
T const & angle) T const & angle
{ )
{
detail::tvec3<T> Result = v; detail::tvec3<T> Result = v;
const T Cos = cos(radians(angle)); const T Cos = cos(radians(angle));
const T Sin = sin(radians(angle)); const T Sin = sin(radians(angle));
Result.y = v.y * Cos - v.z * Sin; Result.y = v.y * Cos - v.z * Sin;
Result.z = v.y * Sin + v.z * Cos; Result.z = v.y * Sin + v.z * Cos;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateY( GLM_FUNC_QUALIFIER detail::tvec3<T> rotateY
(
detail::tvec3<T> const & v, detail::tvec3<T> const & v,
T const & angle) T const & angle
{ )
{
detail::tvec3<T> Result = v; detail::tvec3<T> Result = v;
const T Cos = cos(radians(angle)); const T Cos = cos(radians(angle));
const T Sin = sin(radians(angle)); const T Sin = sin(radians(angle));
Result.x = v.x * Cos + v.z * Sin; Result.x = v.x * Cos + v.z * Sin;
Result.z = -v.x * Sin + v.z * Cos; Result.z = -v.x * Sin + v.z * Cos;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateZ( GLM_FUNC_QUALIFIER detail::tvec3<T> rotateZ
(
detail::tvec3<T> const & v, detail::tvec3<T> const & v,
T const & angle) T const & angle
{ )
{
detail::tvec3<T> Result = v; detail::tvec3<T> Result = v;
const T Cos = cos(radians(angle)); const T Cos = cos(radians(angle));
const T Sin = sin(radians(angle)); const T Sin = sin(radians(angle));
Result.x = v.x * Cos - v.y * Sin; Result.x = v.x * Cos - v.y * Sin;
Result.y = v.x * Sin + v.y * Cos; Result.y = v.x * Sin + v.y * Cos;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateX( GLM_FUNC_QUALIFIER detail::tvec4<T> rotateX
(
detail::tvec4<T> const & v, detail::tvec4<T> const & v,
T const & angle) T const & angle
{ )
{
detail::tvec4<T> Result = v; detail::tvec4<T> Result = v;
const T Cos = cos(radians(angle)); const T Cos = cos(radians(angle));
const T Sin = sin(radians(angle)); const T Sin = sin(radians(angle));
Result.y = v.y * Cos - v.z * Sin; Result.y = v.y * Cos - v.z * Sin;
Result.z = v.y * Sin + v.z * Cos; Result.z = v.y * Sin + v.z * Cos;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateY( GLM_FUNC_QUALIFIER detail::tvec4<T> rotateY
(
detail::tvec4<T> const & v, detail::tvec4<T> const & v,
T const & angle) T const & angle
{ )
{
detail::tvec4<T> Result = v; detail::tvec4<T> Result = v;
const T Cos = cos(radians(angle)); const T Cos = cos(radians(angle));
const T Sin = sin(radians(angle)); const T Sin = sin(radians(angle));
Result.x = v.x * Cos + v.z * Sin; Result.x = v.x * Cos + v.z * Sin;
Result.z = -v.x * Sin + v.z * Cos; Result.z = -v.x * Sin + v.z * Cos;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateZ( GLM_FUNC_QUALIFIER detail::tvec4<T> rotateZ
(
detail::tvec4<T> const & v, detail::tvec4<T> const & v,
T const & angle) T const & angle
{ )
{
detail::tvec4<T> Result = v; detail::tvec4<T> Result = v;
const T Cos = cos(radians(angle)); const T Cos = cos(radians(angle));
const T Sin = sin(radians(angle)); const T Sin = sin(radians(angle));
Result.x = v.x * Cos - v.y * Sin; Result.x = v.x * Cos - v.y * Sin;
Result.y = v.x * Sin + v.y * Cos; Result.y = v.x * Sin + v.y * Cos;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> orientation( GLM_FUNC_QUALIFIER detail::tmat4x4<T> orientation
(
detail::tvec3<T> const & Normal, detail::tvec3<T> const & Normal,
detail::tvec3<T> const & Up) detail::tvec3<T> const & Up
{ )
{
if(all(equal(Normal, Up))) if(all(equal(Normal, Up)))
return detail::tmat4x4<T>(T(1)); return detail::tmat4x4<T>(T(1));
detail::tvec3<T> RotationAxis = cross(Up, Normal); detail::tvec3<T> RotationAxis = cross(Up, Normal);
T Angle = degrees(acos(dot(Normal, Up))); T Angle = degrees(acos(dot(Normal, Up)));
return rotate(Angle, RotationAxis); return rotate(Angle, RotationAxis);
} }
}//namespace glm }//namespace glm

View File

@ -7,82 +7,82 @@
// File : glm/gtx/transform2.inl // File : glm/gtx/transform2.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearX2D( GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearX2D(
const detail::tmat3x3<T>& m, const detail::tmat3x3<T>& m,
T s) T s)
{ {
detail::tmat3x3<T> r(1); detail::tmat3x3<T> r(1);
r[0][1] = s; r[0][1] = s;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearY2D( GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearY2D(
const detail::tmat3x3<T>& m, const detail::tmat3x3<T>& m,
T s) T s)
{ {
detail::tmat3x3<T> r(1); detail::tmat3x3<T> r(1);
r[1][0] = s; r[1][0] = s;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearX3D( GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearX3D(
const detail::tmat4x4<T>& m, const detail::tmat4x4<T>& m,
T s, T s,
T t) T t)
{ {
detail::tmat4x4<T> r(1); detail::tmat4x4<T> r(1);
r[1][0] = s; r[1][0] = s;
r[2][0] = t; r[2][0] = t;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearY3D( GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearY3D(
const detail::tmat4x4<T>& m, const detail::tmat4x4<T>& m,
T s, T s,
T t) T t)
{ {
detail::tmat4x4<T> r(1); detail::tmat4x4<T> r(1);
r[0][1] = s; r[0][1] = s;
r[2][1] = t; r[2][1] = t;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearZ3D( GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearZ3D(
const detail::tmat4x4<T>& m, const detail::tmat4x4<T>& m,
T s, T s,
T t) T t)
{ {
detail::tmat4x4<T> r(1); detail::tmat4x4<T> r(1);
r[0][2] = s; r[0][2] = s;
r[1][2] = t; r[1][2] = t;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> reflect2D( GLM_FUNC_QUALIFIER detail::tmat3x3<T> reflect2D(
const detail::tmat3x3<T>& m, const detail::tmat3x3<T>& m,
const detail::tvec3<T>& normal) const detail::tvec3<T>& normal)
{ {
detail::tmat3x3<T> r(1); detail::tmat3x3<T> r(1);
r[0][0] = 1 - 2 * normal.x * normal.x; r[0][0] = 1 - 2 * normal.x * normal.x;
r[0][1] = -2 * normal.x * normal.y; r[0][1] = -2 * normal.x * normal.y;
r[1][0] = -2 * normal.x * normal.y; r[1][0] = -2 * normal.x * normal.y;
r[1][1] = 1 - 2 * normal.y * normal.y; r[1][1] = 1 - 2 * normal.y * normal.y;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> reflect3D( GLM_FUNC_QUALIFIER detail::tmat4x4<T> reflect3D(
const detail::tmat4x4<T>& m, const detail::tmat4x4<T>& m,
const detail::tvec3<T>& normal) const detail::tvec3<T>& normal)
{ {
detail::tmat4x4<T> r(1); detail::tmat4x4<T> r(1);
r[0][0] = 1 - 2 * normal.x * normal.x; r[0][0] = 1 - 2 * normal.x * normal.x;
r[0][1] = -2 * normal.x * normal.y; r[0][1] = -2 * normal.x * normal.y;
@ -96,26 +96,26 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> reflect3D(
r[2][1] = -2 * normal.y * normal.z; r[2][1] = -2 * normal.y * normal.z;
r[2][2] = 1 - 2 * normal.z * normal.z; r[2][2] = 1 - 2 * normal.z * normal.z;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> proj2D( GLM_FUNC_QUALIFIER detail::tmat3x3<T> proj2D(
const detail::tmat3x3<T>& m, const detail::tmat3x3<T>& m,
const detail::tvec3<T>& normal) const detail::tvec3<T>& normal)
{ {
detail::tmat3x3<T> r(1); detail::tmat3x3<T> r(1);
r[0][0] = 1 - normal.x * normal.x; r[0][0] = 1 - normal.x * normal.x;
r[0][1] = - normal.x * normal.y; r[0][1] = - normal.x * normal.y;
r[1][0] = - normal.x * normal.y; r[1][0] = - normal.x * normal.y;
r[1][1] = 1 - normal.y * normal.y; r[1][1] = 1 - normal.y * normal.y;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> proj3D( GLM_FUNC_QUALIFIER detail::tmat4x4<T> proj3D(
const detail::tmat4x4<T>& m, const detail::tmat4x4<T>& m,
const detail::tvec3<T>& normal) const detail::tvec3<T>& normal)
{ {
detail::tmat4x4<T> r(1); detail::tmat4x4<T> r(1);
r[0][0] = 1 - normal.x * normal.x; r[0][0] = 1 - normal.x * normal.x;
r[0][1] = - normal.x * normal.y; r[0][1] = - normal.x * normal.y;
@ -127,29 +127,28 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> proj3D(
r[2][1] = - normal.y * normal.z; r[2][1] = - normal.y * normal.z;
r[2][2] = 1 - normal.z * normal.z; r[2][2] = 1 - normal.z * normal.z;
return m * r; return m * r;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias( GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias(
T scale, T scale,
T bias) T bias)
{ {
detail::tmat4x4<T> result; detail::tmat4x4<T> result;
result[3] = detail::tvec4<T>(detail::tvec3<T>(bias), T(1)); result[3] = detail::tvec4<T>(detail::tvec3<T>(bias), T(1));
result[0][0] = scale; result[0][0] = scale;
result[1][1] = scale; result[1][1] = scale;
result[2][2] = scale; result[2][2] = scale;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias( GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias(
const detail::tmat4x4<T>& m, const detail::tmat4x4<T>& m,
T scale, T scale,
T bias) T bias)
{ {
return m * scaleBias(scale, bias); return m * scaleBias(scale, bias);
} }
}//namespace glm }//namespace glm

View File

@ -42,34 +42,34 @@ typedef union
} ieee_double_shape_type; } ieee_double_shape_type;
#define GLM_EXTRACT_WORDS(ix0,ix1,d) \ #define GLM_EXTRACT_WORDS(ix0,ix1,d) \
do { \ do { \
ieee_double_shape_type ew_u; \ ieee_double_shape_type ew_u; \
ew_u.value = (d); \ ew_u.value = (d); \
(ix0) = ew_u.parts.msw; \ (ix0) = ew_u.parts.msw; \
(ix1) = ew_u.parts.lsw; \ (ix1) = ew_u.parts.lsw; \
} while (0) } while (0)
#define GLM_GET_FLOAT_WORD(i,d) \ #define GLM_GET_FLOAT_WORD(i,d) \
do { \ do { \
ieee_float_shape_type gf_u; \ ieee_float_shape_type gf_u; \
gf_u.value = (d); \ gf_u.value = (d); \
(i) = gf_u.word; \ (i) = gf_u.word; \
} while (0) } while (0)
#define GLM_SET_FLOAT_WORD(d,i) \ #define GLM_SET_FLOAT_WORD(d,i) \
do { \ do { \
ieee_float_shape_type sf_u; \ ieee_float_shape_type sf_u; \
sf_u.word = (i); \ sf_u.word = (i); \
(d) = sf_u.value; \ (d) = sf_u.value; \
} while (0) } while (0)
#define GLM_INSERT_WORDS(d,ix0,ix1) \ #define GLM_INSERT_WORDS(d,ix0,ix1) \
do { \ do { \
ieee_double_shape_type iw_u; \ ieee_double_shape_type iw_u; \
iw_u.parts.msw = (ix0); \ iw_u.parts.msw = (ix0); \
iw_u.parts.lsw = (ix1); \ iw_u.parts.lsw = (ix1); \
(d) = iw_u.value; \ (d) = iw_u.value; \
} while (0) } while (0)
namespace glm{ namespace glm{
namespace detail namespace detail
@ -181,85 +181,85 @@ namespace detail
# define GLM_NEXT_AFTER_DBL(x, toward) nextafter((x), (toward)) # define GLM_NEXT_AFTER_DBL(x, toward) nextafter((x), (toward))
#endif #endif
namespace glm{ namespace glm
GLM_FUNC_QUALIFIER float next_float(float const & x)
{ {
GLM_FUNC_QUALIFIER float next_float(float const & x)
{
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::max()); return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::max());
} }
GLM_FUNC_QUALIFIER double next_float(double const & x) GLM_FUNC_QUALIFIER double next_float(double const & x)
{ {
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::max()); return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::max());
} }
template<typename T, template<typename> class vecType> template<typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x) GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x)
{ {
vecType<T> Result; vecType<T> Result;
for(std::size_t i = 0; i < Result.length(); ++i) for(std::size_t i = 0; i < Result.length(); ++i)
Result[i] = next_float(x[i]); Result[i] = next_float(x[i]);
return Result; return Result;
} }
GLM_FUNC_QUALIFIER float prev_float(float const & x) GLM_FUNC_QUALIFIER float prev_float(float const & x)
{ {
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::min()); return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::min());
} }
GLM_FUNC_QUALIFIER double prev_float(double const & x) GLM_FUNC_QUALIFIER double prev_float(double const & x)
{ {
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::min()); return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::min());
} }
template<typename T, template<typename> class vecType> template<typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x) GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x)
{ {
vecType<T> Result; vecType<T> Result;
for(std::size_t i = 0; i < Result.length(); ++i) for(std::size_t i = 0; i < Result.length(); ++i)
Result[i] = prev_float(x[i]); Result[i] = prev_float(x[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps) GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps)
{ {
T temp = x; T temp = x;
for(std::size_t i = 0; i < ulps; ++i) for(std::size_t i = 0; i < ulps; ++i)
temp = next_float(temp); temp = next_float(temp);
return temp; return temp;
} }
template<typename T, template<typename> class vecType> template<typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x, vecType<uint> const & ulps) GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x, vecType<uint> const & ulps)
{ {
vecType<T> Result; vecType<T> Result;
for(std::size_t i = 0; i < Result.length(); ++i) for(std::size_t i = 0; i < Result.length(); ++i)
Result[i] = next_float(x[i], ulps[i]); Result[i] = next_float(x[i], ulps[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps) GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps)
{ {
T temp = x; T temp = x;
for(std::size_t i = 0; i < ulps; ++i) for(std::size_t i = 0; i < ulps; ++i)
temp = prev_float(temp); temp = prev_float(temp);
return temp; return temp;
} }
template<typename T, template<typename> class vecType> template<typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x, vecType<uint> const & ulps) GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x, vecType<uint> const & ulps)
{ {
vecType<T> Result; vecType<T> Result;
for(std::size_t i = 0; i < Result.length(); ++i) for(std::size_t i = 0; i < Result.length(); ++i)
Result[i] = prev_float(x[i], ulps[i]); Result[i] = prev_float(x[i], ulps[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y) GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y)
{ {
uint ulp = 0; uint ulp = 0;
if(x < y) if(x < y)
@ -286,113 +286,14 @@ GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y)
} }
return ulp; return ulp;
} }
template<typename T, template<typename> class vecType> template<typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y) GLM_FUNC_QUALIFIER vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y)
{ {
vecType<uint> Result; vecType<uint> Result;
for(std::size_t i = 0; i < Result.length(); ++i) for(std::size_t i = 0; i < Result.length(); ++i)
Result[i] = float_distance(x[i], y[i]); Result[i] = float_distance(x[i], y[i]);
return Result; return Result;
}
/*
inline std::size_t ulp
(
detail::thalf const & a,
detail::thalf const & b
)
{
std::size_t Count = 0;
float TempA(a);
float TempB(b);
//while((TempA = _nextafterf(TempA, TempB)) != TempB)
++Count;
return Count;
}
inline std::size_t ulp
(
float const & a,
float const & b
)
{
std::size_t Count = 0;
float Temp = a;
//while((Temp = _nextafterf(Temp, b)) != b)
{
std::cout << Temp << " " << b << std::endl;
++Count;
} }
return Count;
}
inline std::size_t ulp
(
double const & a,
double const & b
)
{
std::size_t Count = 0;
double Temp = a;
//while((Temp = _nextafter(Temp, b)) != b)
{
std::cout << Temp << " " << b << std::endl;
++Count;
}
return Count;
}
template <typename T>
inline std::size_t ulp
(
detail::tvec2<T> const & a,
detail::tvec2<T> const & b
)
{
std::size_t ulps[] =
{
ulp(a[0], b[0]),
ulp(a[1], b[1])
};
return glm::max(ulps[0], ulps[1]);
}
template <typename T>
inline std::size_t ulp
(
detail::tvec3<T> const & a,
detail::tvec3<T> const & b
)
{
std::size_t ulps[] =
{
ulp(a[0], b[0]),
ulp(a[1], b[1]),
ulp(a[2], b[2])
};
return glm::max(glm::max(ulps[0], ulps[1]), ulps[2]);
}
template <typename T>
inline std::size_t ulp
(
detail::tvec4<T> const & a,
detail::tvec4<T> const & b
)
{
std::size_t ulps[] =
{
ulp(a[0], b[0]),
ulp(a[1], b[1]),
ulp(a[2], b[2]),
ulp(a[3], b[3])
};
return glm::max(glm::max(ulps[0], ulps[1]), glm::max(ulps[2], ulps[3]));
}
*/
}//namespace glm }//namespace glm

View File

@ -7,7 +7,7 @@
// File : glm/gtx/unsigned_int.inl // File : glm/gtx/unsigned_int.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
}//namespace glm }//namespace glm

View File

@ -7,48 +7,47 @@
// File : glm/gtx/vector_access.inl // File : glm/gtx/vector_access.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER void set GLM_FUNC_QUALIFIER void set
( (
detail::tvec2<valType>& v, detail::tvec2<valType>& v,
valType const & x, valType const & x,
valType const & y valType const & y
) )
{ {
v.x = x; v.x = x;
v.y = y; v.y = y;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER void set GLM_FUNC_QUALIFIER void set
( (
detail::tvec3<valType>& v, detail::tvec3<valType>& v,
valType const & x, valType const & x,
valType const & y, valType const & y,
valType const & z valType const & z
) )
{ {
v.x = x; v.x = x;
v.y = y; v.y = y;
v.z = z; v.z = z;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER void set GLM_FUNC_QUALIFIER void set
( (
detail::tvec4<valType>& v, detail::tvec4<valType>& v,
valType const & x, valType const & x,
valType const & y, valType const & y,
valType const & z, valType const & z,
valType const & w valType const & w
) )
{ {
v.x = x; v.x = x;
v.y = y; v.y = y;
v.z = z; v.z = z;
v.w = w; v.w = w;
} }
}//namespace glm }//namespace glm

View File

@ -7,48 +7,47 @@
// File : glm/gtx/vector_angle.inl // File : glm/gtx/vector_angle.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type angle GLM_FUNC_QUALIFIER typename genType::value_type angle
( (
genType const & x, genType const & x,
genType const & y genType const & y
) )
{ {
return degrees(acos(dot(x, y))); return degrees(acos(dot(x, y)));
} }
//! \todo epsilon is hard coded to 0.01 //! \todo epsilon is hard coded to 0.01
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType orientedAngle GLM_FUNC_QUALIFIER valType orientedAngle
( (
detail::tvec2<valType> const & x, detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y detail::tvec2<valType> const & y
) )
{ {
valType Angle = glm::degrees(acos(dot(x, y))); valType Angle = glm::degrees(acos(dot(x, y)));
detail::tvec2<valType> TransformedVector = glm::rotate(x, Angle); detail::tvec2<valType> TransformedVector = glm::rotate(x, Angle);
if(all(equalEpsilon(y, TransformedVector, valType(0.01)))) if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
return Angle; return Angle;
else else
return -Angle; return -Angle;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType orientedAngle GLM_FUNC_QUALIFIER valType orientedAngle
( (
detail::tvec3<valType> const & x, detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y, detail::tvec3<valType> const & y,
detail::tvec3<valType> const & ref detail::tvec3<valType> const & ref
) )
{ {
valType Angle = glm::degrees(glm::acos(glm::dot(x, y))); valType Angle = glm::degrees(glm::acos(glm::dot(x, y)));
if(glm::dot(ref, glm::cross(x, y)) < valType(0)) if(glm::dot(ref, glm::cross(x, y)) < valType(0))
return -Angle; return -Angle;
else else
return Angle; return Angle;
} }
}//namespace glm }//namespace glm

View File

@ -12,159 +12,158 @@
#include <cassert> #include <cassert>
namespace glm{ namespace glm
{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER bool areCollinear GLM_FUNC_QUALIFIER bool areCollinear
( (
detail::tvec2<T> const & v0, detail::tvec2<T> const & v0,
detail::tvec2<T> const & v1, detail::tvec2<T> const & v1,
T const & epsilon T const & epsilon
) )
{ {
return length(cross(detail::tvec3<T>(v0, T(0)), detail::tvec3<T>(v1, T(0)))) < epsilon; return length(cross(detail::tvec3<T>(v0, T(0)), detail::tvec3<T>(v1, T(0)))) < epsilon;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER bool areCollinear GLM_FUNC_QUALIFIER bool areCollinear
( (
detail::tvec3<T> const & v0, detail::tvec3<T> const & v0,
detail::tvec3<T> const & v1, detail::tvec3<T> const & v1,
T const & epsilon T const & epsilon
) )
{ {
return length(cross(v0, v1)) < epsilon; return length(cross(v0, v1)) < epsilon;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER bool areCollinear GLM_FUNC_QUALIFIER bool areCollinear
( (
detail::tvec4<T> const & v0, detail::tvec4<T> const & v0,
detail::tvec4<T> const & v1, detail::tvec4<T> const & v1,
T const & epsilon T const & epsilon
) )
{ {
return length(cross(detail::tvec3<T>(v0), detail::tvec3<T>(v1))) < epsilon; return length(cross(detail::tvec3<T>(v0), detail::tvec3<T>(v1))) < epsilon;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool areOpposite GLM_FUNC_QUALIFIER bool areOpposite
( (
genType const & v0, genType const & v0,
genType const & v1, genType const & v1,
typename genType::value_type const & epsilon typename genType::value_type const & epsilon
) )
{ {
assert(isNormalized(v0) && isNormalized(v1)); assert(isNormalized(v0) && isNormalized(v1));
return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon); return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon);
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool areOrthogonal GLM_FUNC_QUALIFIER bool areOrthogonal
( (
genType const & v0, genType const & v0,
genType const & v1, genType const & v1,
typename genType::value_type const & epsilon typename genType::value_type const & epsilon
) )
{ {
return abs(dot(v0, v1)) <= max( return abs(dot(v0, v1)) <= max(
typename genType::value_type(1), typename genType::value_type(1),
length(v0)) * max( length(v0)) * max(
typename genType::value_type(1), typename genType::value_type(1),
length(v1)) * epsilon; length(v1)) * epsilon;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool isNormalized GLM_FUNC_QUALIFIER bool isNormalized
( (
genType const & v, genType const & v,
typename genType::value_type const & epsilon typename genType::value_type const & epsilon
) )
{ {
return abs(length(v) - typename genType::value_type(1)) <= typename genType::value_type(2) * epsilon; return abs(length(v) - typename genType::value_type(1)) <= typename genType::value_type(2) * epsilon;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool isNull GLM_FUNC_QUALIFIER bool isNull
( (
genType const & v, genType const & v,
typename genType::value_type const & epsilon typename genType::value_type const & epsilon
) )
{ {
return length(v) <= epsilon; return length(v) <= epsilon;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER bool isCompNull GLM_FUNC_QUALIFIER bool isCompNull
( (
T const & s, T const & s,
T const & epsilon T const & epsilon
) )
{ {
return abs(s) < epsilon; return abs(s) < epsilon;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<bool> isCompNull GLM_FUNC_QUALIFIER detail::tvec2<bool> isCompNull
( (
detail::tvec2<T> const & v, detail::tvec2<T> const & v,
T const & epsilon) T const & epsilon)
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
(abs(v.x) < epsilon), (abs(v.x) < epsilon),
(abs(v.y) < epsilon)); (abs(v.y) < epsilon));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<bool> isCompNull GLM_FUNC_QUALIFIER detail::tvec3<bool> isCompNull
( (
detail::tvec3<T> const & v, detail::tvec3<T> const & v,
T const & epsilon T const & epsilon
) )
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
abs(v.x) < epsilon, abs(v.x) < epsilon,
abs(v.y) < epsilon, abs(v.y) < epsilon,
abs(v.z) < epsilon); abs(v.z) < epsilon);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<bool> isCompNull GLM_FUNC_QUALIFIER detail::tvec4<bool> isCompNull
( (
detail::tvec4<T> const & v, detail::tvec4<T> const & v,
T const & epsilon T const & epsilon
) )
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
abs(v.x) < epsilon, abs(v.x) < epsilon,
abs(v.y) < epsilon, abs(v.y) < epsilon,
abs(v.z) < epsilon, abs(v.z) < epsilon,
abs(v.w) < epsilon); abs(v.w) < epsilon);
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool areOrthonormal GLM_FUNC_QUALIFIER bool areOrthonormal
( (
genType const & v0, genType const & v0,
genType const & v1, genType const & v1,
typename genType::value_type const & epsilon typename genType::value_type const & epsilon
) )
{ {
return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon); return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon);
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool areSimilar GLM_FUNC_QUALIFIER bool areSimilar
( (
genType const & v0, genType const & v0,
genType const & v1, genType const & v1,
typename genType::value_type const & epsilon typename genType::value_type const & epsilon
) )
{ {
bool similar = true; bool similar = true;
for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++) for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++)
similar = (abs(v0[i] - v1[i]) <= epsilon); similar = (abs(v0[i] - v1[i]) <= epsilon);
return similar; return similar;
} }
}//namespace glm }//namespace glm

View File

@ -7,119 +7,118 @@
// File : glm/gtx/verbose_operator.inl // File : glm/gtx/verbose_operator.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER genType add(genType const & a, genType const & b)
{ {
template <typename genType>
GLM_FUNC_QUALIFIER genType add(genType const & a, genType const & b)
{
return a + b; return a + b;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType sub(genType const & a, genType const & b) GLM_FUNC_QUALIFIER genType sub(genType const & a, genType const & b)
{ {
return a - b; return a - b;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> mul GLM_FUNC_QUALIFIER detail::tmat2x2<T> mul
( (
detail::tmat2x2<T> const & a, detail::tmat2x2<T> const & a,
detail::tmat2x2<T> const & b detail::tmat2x2<T> const & b
) )
{ {
return a * b; return a * b;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> mul GLM_FUNC_QUALIFIER detail::tmat3x3<T> mul
( (
detail::tmat3x3<T> const & a, detail::tmat3x3<T> const & a,
detail::tmat3x3<T> const & b detail::tmat3x3<T> const & b
) )
{ {
return a * b; return a * b;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> mul GLM_FUNC_QUALIFIER detail::tmat4x4<T> mul
( (
detail::tmat4x4<T> const & a, detail::tmat4x4<T> const & a,
detail::tmat4x4<T> const & b detail::tmat4x4<T> const & b
) )
{ {
return a * b; return a * b;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> mul GLM_FUNC_QUALIFIER detail::tvec2<T> mul
( (
detail::tmat2x2<T> const & m, detail::tmat2x2<T> const & m,
detail::tvec2<T> const & v detail::tvec2<T> const & v
) )
{ {
return m * v; return m * v;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> mul GLM_FUNC_QUALIFIER detail::tvec3<T> mul
( (
detail::tmat3x3<T> const & m, detail::tmat3x3<T> const & m,
detail::tvec3<T> const & v) detail::tvec3<T> const & v)
{ {
return m * v; return m * v;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> mul GLM_FUNC_QUALIFIER detail::tvec4<T> mul
( (
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
detail::tvec4<T> const & v detail::tvec4<T> const & v
) )
{ {
return m * v; return m * v;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> mul GLM_FUNC_QUALIFIER detail::tvec2<T> mul
( (
detail::tvec2<T> const & v, detail::tvec2<T> const & v,
detail::tmat2x2<T> const & m detail::tmat2x2<T> const & m
) )
{ {
return v * m; return v * m;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> mul GLM_FUNC_QUALIFIER detail::tvec3<T> mul
( (
detail::tvec3<T> const & v, detail::tvec3<T> const & v,
detail::tmat3x3<T> const & m detail::tmat3x3<T> const & m
) )
{ {
return v * m; return v * m;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> mul GLM_FUNC_QUALIFIER detail::tvec4<T> mul
( (
detail::tvec4<T> const & v, detail::tvec4<T> const & v,
detail::tmat4x4<T> const & m detail::tmat4x4<T> const & m
) )
{ {
return v * m; return v * m;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType div(genType const & a, genType const & b) GLM_FUNC_QUALIFIER genType div(genType const & a, genType const & b)
{ {
return a / b; return a / b;
} }
template <typename genTypeT, typename genTypeU, typename genTypeV> template <typename genTypeT, typename genTypeU, typename genTypeV>
GLM_FUNC_QUALIFIER genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c) GLM_FUNC_QUALIFIER genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c)
{ {
return a * b + c; return a * b + c;
} }
}//namespace glm }//namespace glm

View File

@ -10,110 +10,110 @@
// - GLM core // - GLM core
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
template <typename genType>
GLM_FUNC_QUALIFIER genType clamp
(
genType const & Texcoord
)
{ {
template <typename genType>
GLM_FUNC_QUALIFIER genType clamp
(
genType const & Texcoord
)
{
return glm::clamp(Texcoord, genType(0), genType(1)); return glm::clamp(Texcoord, genType(0), genType(1));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> clamp GLM_FUNC_QUALIFIER detail::tvec2<T> clamp
( (
detail::tvec2<T> const & Texcoord detail::tvec2<T> const & Texcoord
) )
{ {
detail::tvec2<T> Result; detail::tvec2<T> Result;
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]); Result[i] = clamp(Texcoord[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> clamp GLM_FUNC_QUALIFIER detail::tvec3<T> clamp
( (
detail::tvec3<T> const & Texcoord detail::tvec3<T> const & Texcoord
) )
{ {
detail::tvec3<T> Result; detail::tvec3<T> Result;
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]); Result[i] = clamp(Texcoord[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> clamp GLM_FUNC_QUALIFIER detail::tvec4<T> clamp
( (
detail::tvec4<T> const & Texcoord detail::tvec4<T> const & Texcoord
) )
{ {
detail::tvec4<T> Result; detail::tvec4<T> Result;
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]); Result[i] = clamp(Texcoord[i]);
return Result; return Result;
} }
//////////////////////// ////////////////////////
// repeat // repeat
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType repeat GLM_FUNC_QUALIFIER genType repeat
( (
genType const & Texcoord genType const & Texcoord
) )
{ {
return glm::fract(Texcoord); return glm::fract(Texcoord);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> repeat GLM_FUNC_QUALIFIER detail::tvec2<T> repeat
( (
detail::tvec2<T> const & Texcoord detail::tvec2<T> const & Texcoord
) )
{ {
detail::tvec2<T> Result; detail::tvec2<T> Result;
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
Result[i] = repeat(Texcoord[i]); Result[i] = repeat(Texcoord[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> repeat GLM_FUNC_QUALIFIER detail::tvec3<T> repeat
( (
detail::tvec3<T> const & Texcoord detail::tvec3<T> const & Texcoord
) )
{ {
detail::tvec3<T> Result; detail::tvec3<T> Result;
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
Result[i] = repeat(Texcoord[i]); Result[i] = repeat(Texcoord[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> repeat GLM_FUNC_QUALIFIER detail::tvec4<T> repeat
( (
detail::tvec4<T> const & Texcoord detail::tvec4<T> const & Texcoord
) )
{ {
detail::tvec4<T> Result; detail::tvec4<T> Result;
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = repeat(Texcoord[i]); Result[i] = repeat(Texcoord[i]);
return Result; return Result;
} }
//////////////////////// ////////////////////////
// mirrorRepeat // mirrorRepeat
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType mirrorRepeat GLM_FUNC_QUALIFIER genType mirrorRepeat
( (
genType const & Texcoord genType const & Texcoord
) )
{ {
genType const Clamp = genType(int(glm::floor(Texcoord)) % 2); genType const Clamp = genType(int(glm::floor(Texcoord)) % 2);
genType const Floor = glm::floor(Texcoord); genType const Floor = glm::floor(Texcoord);
genType const Rest = Texcoord - Floor; genType const Rest = Texcoord - Floor;
@ -125,42 +125,41 @@ GLM_FUNC_QUALIFIER genType mirrorRepeat
else else
Out = Rest; Out = Rest;
return Out; return Out;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> mirrorRepeat GLM_FUNC_QUALIFIER detail::tvec2<T> mirrorRepeat
( (
detail::tvec2<T> const & Texcoord detail::tvec2<T> const & Texcoord
) )
{ {
detail::tvec2<T> Result; detail::tvec2<T> Result;
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
Result[i] = mirrorRepeat(Texcoord[i]); Result[i] = mirrorRepeat(Texcoord[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> mirrorRepeat GLM_FUNC_QUALIFIER detail::tvec3<T> mirrorRepeat
( (
detail::tvec3<T> const & Texcoord detail::tvec3<T> const & Texcoord
) )
{ {
detail::tvec3<T> Result; detail::tvec3<T> Result;
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
Result[i] = mirrorRepeat(Texcoord[i]); Result[i] = mirrorRepeat(Texcoord[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> mirrorRepeat GLM_FUNC_QUALIFIER detail::tvec4<T> mirrorRepeat
( (
detail::tvec4<T> const & Texcoord detail::tvec4<T> const & Texcoord
) )
{ {
detail::tvec4<T> Result; detail::tvec4<T> Result;
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = mirrorRepeat(Texcoord[i]); Result[i] = mirrorRepeat(Texcoord[i]);
return Result; return Result;
} }
}//namespace glm }//namespace glm