Vectorize and reformatting
This commit is contained in:
parent
7e9ca13cde
commit
8d843a448a
@ -7,38 +7,37 @@
|
||||
// File : glm/gtx/gradient_paint.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename valType>
|
||||
valType radialGradient
|
||||
(
|
||||
detail::tvec2<valType> const & Center,
|
||||
valType const & Radius,
|
||||
detail::tvec2<valType> const & Focal,
|
||||
detail::tvec2<valType> const & Position
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
detail::tvec2<valType> F = Focal - Center;
|
||||
detail::tvec2<valType> D = Position - Focal;
|
||||
valType Radius2 = pow2(Radius);
|
||||
valType Fx2 = pow2(F.x);
|
||||
valType Fy2 = pow2(F.y);
|
||||
template <typename valType>
|
||||
valType radialGradient
|
||||
(
|
||||
detail::tvec2<valType> const & Center,
|
||||
valType const & Radius,
|
||||
detail::tvec2<valType> const & Focal,
|
||||
detail::tvec2<valType> const & Position
|
||||
)
|
||||
{
|
||||
detail::tvec2<valType> F = Focal - Center;
|
||||
detail::tvec2<valType> D = Position - Focal;
|
||||
valType Radius2 = pow2(Radius);
|
||||
valType Fx2 = pow2(F.x);
|
||||
valType Fy2 = pow2(F.y);
|
||||
|
||||
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);
|
||||
return Numerator / Denominator;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
valType linearGradient
|
||||
(
|
||||
detail::tvec2<valType> const & Point0,
|
||||
detail::tvec2<valType> const & Point1,
|
||||
detail::tvec2<valType> const & Position
|
||||
)
|
||||
{
|
||||
detail::tvec2<valType> Dist = Point1 - Point0;
|
||||
return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist);
|
||||
}
|
||||
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);
|
||||
return Numerator / Denominator;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
valType linearGradient
|
||||
(
|
||||
detail::tvec2<valType> const & Point0,
|
||||
detail::tvec2<valType> const & Point1,
|
||||
detail::tvec2<valType> const & Position
|
||||
)
|
||||
{
|
||||
detail::tvec2<valType> Dist = Point1 - Point0;
|
||||
return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,24 +7,27 @@
|
||||
// File : glm/gtx/handed_coordinate_space.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool rightHanded(
|
||||
detail::tvec3<T> const & tangent,
|
||||
detail::tvec3<T> const & binormal,
|
||||
detail::tvec3<T> const & normal)
|
||||
namespace glm
|
||||
{
|
||||
return dot(cross(normal, tangent), binormal) > T(0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool leftHanded(
|
||||
detail::tvec3<T> const & tangent,
|
||||
detail::tvec3<T> const & binormal,
|
||||
detail::tvec3<T> const & normal)
|
||||
{
|
||||
return dot(cross(normal, tangent), binormal) < T(0);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool rightHanded
|
||||
(
|
||||
detail::tvec3<T> const & tangent,
|
||||
detail::tvec3<T> const & binormal,
|
||||
detail::tvec3<T> const & normal
|
||||
)
|
||||
{
|
||||
return dot(cross(normal, tangent), binormal) > T(0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool leftHanded
|
||||
(
|
||||
detail::tvec3<T> const & tangent,
|
||||
detail::tvec3<T> const & binormal,
|
||||
detail::tvec3<T> const & normal
|
||||
)
|
||||
{
|
||||
return dot(cross(normal, tangent), binormal) < T(0);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -55,57 +55,57 @@ namespace glm
|
||||
//! From GLM_GTX_inertia extension.
|
||||
template <typename T>
|
||||
detail::tmat3x3<T> boxInertia3(
|
||||
const T Mass,
|
||||
const detail::tvec3<T>& Scale);
|
||||
T const & Mass,
|
||||
detail::tvec3<T> const & Scale);
|
||||
|
||||
//! Build an inertia matrix for a box.
|
||||
//! From GLM_GTX_inertia extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> boxInertia4(
|
||||
const T Mass,
|
||||
const detail::tvec3<T>& Scale);
|
||||
T const & Mass,
|
||||
detail::tvec3<T> const & Scale);
|
||||
|
||||
//! Build an inertia matrix for a disk.
|
||||
//! From GLM_GTX_inertia extension.
|
||||
template <typename T>
|
||||
detail::tmat3x3<T> diskInertia3(
|
||||
const T Mass,
|
||||
const T Radius);
|
||||
T const & Mass,
|
||||
T const & Radius);
|
||||
|
||||
//! Build an inertia matrix for a disk.
|
||||
//! From GLM_GTX_inertia extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> diskInertia4(
|
||||
const T Mass,
|
||||
const T Radius);
|
||||
T const & Mass,
|
||||
T const & Radius);
|
||||
|
||||
//! Build an inertia matrix for a ball.
|
||||
//! From GLM_GTX_inertia extension.
|
||||
template <typename T>
|
||||
detail::tmat3x3<T> ballInertia3(
|
||||
const T Mass,
|
||||
const T Radius);
|
||||
T const & Mass,
|
||||
T const & Radius);
|
||||
|
||||
//! Build an inertia matrix for a ball.
|
||||
//! From GLM_GTX_inertia extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> ballInertia4(
|
||||
const T Mass,
|
||||
const T Radius);
|
||||
T const & Mass,
|
||||
T const & Radius);
|
||||
|
||||
//! Build an inertia matrix for a sphere.
|
||||
//! From GLM_GTX_inertia extension.
|
||||
template <typename T>
|
||||
detail::tmat3x3<T> sphereInertia3(
|
||||
const T Mass,
|
||||
const T Radius);
|
||||
T const & Mass,
|
||||
T const & Radius);
|
||||
|
||||
//! Build an inertia matrix for a sphere.
|
||||
//! From GLM_GTX_inertia extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> sphereInertia4(
|
||||
const T Mass,
|
||||
const T Radius);
|
||||
T const & Mass,
|
||||
T const & Radius);
|
||||
|
||||
/// @}
|
||||
}// namespace glm
|
||||
|
@ -7,93 +7,108 @@
|
||||
// File : glm/gtx/inertia.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> boxInertia3(
|
||||
const T Mass,
|
||||
const detail::tvec3<T>& Scale)
|
||||
namespace glm
|
||||
{
|
||||
detail::tmat3x3<T> Result(T(1));
|
||||
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[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> boxInertia3
|
||||
(
|
||||
T const & Mass,
|
||||
detail::tvec3<T> const & Scale
|
||||
)
|
||||
{
|
||||
detail::tmat3x3<T> Result(T(1));
|
||||
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[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> boxInertia4(
|
||||
const T Mass,
|
||||
const detail::tvec3<T>& Scale)
|
||||
{
|
||||
detail::tmat4x4<T> Result(T(1));
|
||||
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[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> boxInertia4
|
||||
(
|
||||
T const & Mass,
|
||||
detail::tvec3<T> const & Scale
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T> Result(T(1));
|
||||
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[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> diskInertia3(
|
||||
const T Mass,
|
||||
const T Radius)
|
||||
{
|
||||
T a = Mass * Radius * Radius / T(2);
|
||||
detail::tmat3x3<T> Result(a);
|
||||
Result[2][2] *= T(2);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> diskInertia3
|
||||
(
|
||||
T const & Mass,
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T a = Mass * Radius * Radius / T(2);
|
||||
detail::tmat3x3<T> Result(a);
|
||||
Result[2][2] *= T(2);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> diskInertia4(
|
||||
const T Mass,
|
||||
const T Radius)
|
||||
{
|
||||
T a = Mass * Radius * Radius / T(2);
|
||||
detail::tmat4x4<T> Result(a);
|
||||
Result[2][2] *= T(2);
|
||||
Result[3][3] = T(1);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> diskInertia4
|
||||
(
|
||||
T const & Mass,
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T a = Mass * Radius * Radius / T(2);
|
||||
detail::tmat4x4<T> Result(a);
|
||||
Result[2][2] *= T(2);
|
||||
Result[3][3] = T(1);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> ballInertia3(
|
||||
const T Mass,
|
||||
const T Radius)
|
||||
{
|
||||
T a = T(2) * Mass * Radius * Radius / T(5);
|
||||
return detail::tmat3x3<T>(a);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> ballInertia3
|
||||
(
|
||||
T const & Mass,
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T a = T(2) * Mass * Radius * Radius / T(5);
|
||||
return detail::tmat3x3<T>(a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> ballInertia4(
|
||||
const T Mass,
|
||||
const T Radius)
|
||||
{
|
||||
T a = T(2) * Mass * Radius * Radius / T(5);
|
||||
detail::tmat4x4<T> Result(a);
|
||||
Result[3][3] = T(1);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> ballInertia4
|
||||
(
|
||||
T const & Mass,
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T a = T(2) * Mass * Radius * Radius / T(5);
|
||||
detail::tmat4x4<T> Result(a);
|
||||
Result[3][3] = T(1);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> sphereInertia3(
|
||||
const T Mass,
|
||||
const T Radius)
|
||||
{
|
||||
T a = T(2) * Mass * Radius * Radius / T(3);
|
||||
return detail::tmat3x3<T>(a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> sphereInertia4(
|
||||
const T Mass,
|
||||
const T Radius)
|
||||
{
|
||||
T a = T(2) * Mass * Radius * Radius / T(3);
|
||||
detail::tmat4x4<T> Result(a);
|
||||
Result[3][3] = T(1);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> sphereInertia3
|
||||
(
|
||||
T const & Mass,
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T a = T(2) * Mass * Radius * Radius / T(3);
|
||||
return detail::tmat3x3<T>(a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> sphereInertia4
|
||||
(
|
||||
T const & Mass,
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T a = T(2) * Mass * Radius * Radius / T(3);
|
||||
detail::tmat4x4<T> Result(a);
|
||||
Result[3][3] = T(1);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,11 +7,13 @@
|
||||
// File : glm/gtx/int_10_10_10_2.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast(glm::vec4 const & v)
|
||||
namespace glm
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,35 +7,35 @@
|
||||
// File : glm/gtx/integer.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
// pow
|
||||
GLM_FUNC_QUALIFIER int pow(int x, int y)
|
||||
namespace glm
|
||||
{
|
||||
if(y == 0)
|
||||
return 1;
|
||||
int result = x;
|
||||
for(int i = 1; i < y; ++i)
|
||||
result *= x;
|
||||
return result;
|
||||
}
|
||||
// pow
|
||||
GLM_FUNC_QUALIFIER int pow(int x, int y)
|
||||
{
|
||||
if(y == 0)
|
||||
return 1;
|
||||
int result = x;
|
||||
for(int i = 1; i < y; ++i)
|
||||
result *= x;
|
||||
return result;
|
||||
}
|
||||
|
||||
// sqrt: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387
|
||||
GLM_FUNC_QUALIFIER int sqrt(int x)
|
||||
{
|
||||
if(x <= 1) return x;
|
||||
// sqrt: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387
|
||||
GLM_FUNC_QUALIFIER int sqrt(int x)
|
||||
{
|
||||
if(x <= 1) return x;
|
||||
|
||||
int NextTrial = x >> 1;
|
||||
int CurrentAnswer;
|
||||
int NextTrial = x >> 1;
|
||||
int CurrentAnswer;
|
||||
|
||||
do
|
||||
{
|
||||
CurrentAnswer = NextTrial;
|
||||
NextTrial = (NextTrial + x / NextTrial) >> 1;
|
||||
} while(NextTrial < CurrentAnswer);
|
||||
do
|
||||
{
|
||||
CurrentAnswer = NextTrial;
|
||||
NextTrial = (NextTrial + x / NextTrial) >> 1;
|
||||
} while(NextTrial < CurrentAnswer);
|
||||
|
||||
return CurrentAnswer;
|
||||
}
|
||||
return CurrentAnswer;
|
||||
}
|
||||
|
||||
// Henry Gordon Dietz: http://aggregate.org/MAGIC/
|
||||
namespace detail
|
||||
@ -69,132 +69,132 @@ namespace detail
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
// Henry Gordon Dietz: http://aggregate.org/MAGIC/
|
||||
unsigned int floor_log2(unsigned int x)
|
||||
{
|
||||
x |= (x >> 1);
|
||||
x |= (x >> 2);
|
||||
x |= (x >> 4);
|
||||
x |= (x >> 8);
|
||||
x |= (x >> 16);
|
||||
// Henry Gordon Dietz: http://aggregate.org/MAGIC/
|
||||
unsigned int floor_log2(unsigned int x)
|
||||
{
|
||||
x |= (x >> 1);
|
||||
x |= (x >> 2);
|
||||
x |= (x >> 4);
|
||||
x |= (x >> 8);
|
||||
x |= (x >> 16);
|
||||
|
||||
return(detail::ones32(x) - 1);
|
||||
}
|
||||
return(detail::ones32(x) - 1);
|
||||
}
|
||||
|
||||
// mod
|
||||
GLM_FUNC_QUALIFIER int mod(int x, int y)
|
||||
{
|
||||
return x - y * (x / y);
|
||||
}
|
||||
// mod
|
||||
GLM_FUNC_QUALIFIER int mod(int x, int y)
|
||||
{
|
||||
return x - y * (x / y);
|
||||
}
|
||||
|
||||
// factorial (!12 max, integer only)
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType factorial(genType const & x)
|
||||
{
|
||||
genType Temp = x;
|
||||
genType Result;
|
||||
for(Result = 1; Temp > 1; --Temp)
|
||||
Result *= Temp;
|
||||
return Result;
|
||||
}
|
||||
// factorial (!12 max, integer only)
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType factorial(genType const & x)
|
||||
{
|
||||
genType Temp = x;
|
||||
genType Result;
|
||||
for(Result = 1; Temp > 1; --Temp)
|
||||
Result *= Temp;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> factorial(
|
||||
detail::tvec2<valType> const & x)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
factorial(x.x),
|
||||
factorial(x.y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> factorial(
|
||||
detail::tvec2<valType> const & x)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
factorial(x.x),
|
||||
factorial(x.y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> factorial(
|
||||
detail::tvec3<valType> const & x)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
factorial(x.x),
|
||||
factorial(x.y),
|
||||
factorial(x.z));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> factorial(
|
||||
detail::tvec3<valType> const & x)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
factorial(x.x),
|
||||
factorial(x.y),
|
||||
factorial(x.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> factorial(
|
||||
detail::tvec4<valType> const & x)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
factorial(x.x),
|
||||
factorial(x.y),
|
||||
factorial(x.z),
|
||||
factorial(x.w));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> factorial(
|
||||
detail::tvec4<valType> const & x)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
factorial(x.x),
|
||||
factorial(x.y),
|
||||
factorial(x.z),
|
||||
factorial(x.w));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint pow(uint x, uint y)
|
||||
{
|
||||
uint result = x;
|
||||
for(uint i = 1; i < y; ++i)
|
||||
result *= x;
|
||||
return result;
|
||||
}
|
||||
GLM_FUNC_QUALIFIER uint pow(uint x, uint y)
|
||||
{
|
||||
uint result = x;
|
||||
for(uint i = 1; i < y; ++i)
|
||||
result *= x;
|
||||
return result;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint sqrt(uint x)
|
||||
{
|
||||
if(x <= 1) return x;
|
||||
GLM_FUNC_QUALIFIER uint sqrt(uint x)
|
||||
{
|
||||
if(x <= 1) return x;
|
||||
|
||||
uint NextTrial = x >> 1;
|
||||
uint CurrentAnswer;
|
||||
uint NextTrial = x >> 1;
|
||||
uint CurrentAnswer;
|
||||
|
||||
do
|
||||
{
|
||||
CurrentAnswer = NextTrial;
|
||||
NextTrial = (NextTrial + x / NextTrial) >> 1;
|
||||
} while(NextTrial < CurrentAnswer);
|
||||
do
|
||||
{
|
||||
CurrentAnswer = NextTrial;
|
||||
NextTrial = (NextTrial + x / NextTrial) >> 1;
|
||||
} while(NextTrial < CurrentAnswer);
|
||||
|
||||
return CurrentAnswer;
|
||||
}
|
||||
return CurrentAnswer;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint mod(uint x, uint y)
|
||||
{
|
||||
return x - y * (x / y);
|
||||
}
|
||||
GLM_FUNC_QUALIFIER uint mod(uint x, uint y)
|
||||
{
|
||||
return x - y * (x / y);
|
||||
}
|
||||
|
||||
#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC))
|
||||
|
||||
GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x)
|
||||
{
|
||||
return 31u - findMSB(x);
|
||||
}
|
||||
GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x)
|
||||
{
|
||||
return 31u - findMSB(x);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Hackers Delight: http://www.hackersdelight.org/HDcode/nlz.c.txt
|
||||
GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x)
|
||||
{
|
||||
int y, m, n;
|
||||
// Hackers Delight: http://www.hackersdelight.org/HDcode/nlz.c.txt
|
||||
GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x)
|
||||
{
|
||||
int y, m, n;
|
||||
|
||||
y = -int(x >> 16); // If left half of x is 0,
|
||||
m = (y >> 16) & 16; // set n = 16. If left half
|
||||
n = 16 - m; // is nonzero, set n = 0 and
|
||||
x = x >> m; // shift x right 16.
|
||||
// Now x is of the form 0000xxxx.
|
||||
y = x - 0x100; // If positions 8-15 are 0,
|
||||
m = (y >> 16) & 8; // add 8 to n and shift x left 8.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
y = -int(x >> 16); // If left half of x is 0,
|
||||
m = (y >> 16) & 16; // set n = 16. If left half
|
||||
n = 16 - m; // is nonzero, set n = 0 and
|
||||
x = x >> m; // shift x right 16.
|
||||
// Now x is of the form 0000xxxx.
|
||||
y = x - 0x100; // If positions 8-15 are 0,
|
||||
m = (y >> 16) & 8; // add 8 to n and shift x left 8.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x - 0x1000; // If positions 12-15 are 0,
|
||||
m = (y >> 16) & 4; // add 4 to n and shift x left 4.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
y = x - 0x1000; // If positions 12-15 are 0,
|
||||
m = (y >> 16) & 4; // add 4 to n and shift x left 4.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x - 0x4000; // If positions 14-15 are 0,
|
||||
m = (y >> 16) & 2; // add 2 to n and shift x left 2.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
y = x - 0x4000; // If positions 14-15 are 0,
|
||||
m = (y >> 16) & 2; // add 2 to n and shift x left 2.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x >> 14; // Set y = 0, 1, 2, or 3.
|
||||
m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp.
|
||||
return unsigned(n + 2 - m);
|
||||
}
|
||||
y = x >> 14; // Set y = 0, 1, 2, or 3.
|
||||
m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp.
|
||||
return unsigned(n + 2 - m);
|
||||
}
|
||||
|
||||
#endif//(GLM_COMPILER)
|
||||
|
||||
|
@ -10,188 +10,187 @@
|
||||
#include <cfloat>
|
||||
#include <limits>
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool intersectRayTriangle
|
||||
(
|
||||
genType const & orig, genType const & dir,
|
||||
genType const & v0, genType const & v1, genType const & v2,
|
||||
genType & baryPosition
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
genType e1 = v1 - v0;
|
||||
genType e2 = v2 - v0;
|
||||
|
||||
genType p = glm::cross(dir, e2);
|
||||
|
||||
typename genType::value_type a = glm::dot(e1, p);
|
||||
|
||||
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||
if(a < Epsilon)
|
||||
return false;
|
||||
|
||||
typename genType::value_type f = typename genType::value_type(1.0f) / a;
|
||||
|
||||
genType s = orig - v0;
|
||||
baryPosition.x = f * glm::dot(s, p);
|
||||
if(baryPosition.x < typename genType::value_type(0.0f))
|
||||
return false;
|
||||
if(baryPosition.x > typename genType::value_type(1.0f))
|
||||
return false;
|
||||
|
||||
genType q = glm::cross(s, e1);
|
||||
baryPosition.y = f * glm::dot(dir, q);
|
||||
if(baryPosition.y < typename genType::value_type(0.0f))
|
||||
return false;
|
||||
if(baryPosition.y + baryPosition.x > typename genType::value_type(1.0f))
|
||||
return false;
|
||||
|
||||
baryPosition.z = f * glm::dot(e2, q);
|
||||
|
||||
return baryPosition.z >= typename genType::value_type(0.0f);
|
||||
}
|
||||
|
||||
//template <typename genType>
|
||||
//GLM_FUNC_QUALIFIER bool intersectRayTriangle
|
||||
//(
|
||||
// genType const & orig, genType const & dir,
|
||||
// genType const & vert0, genType const & vert1, genType const & vert2,
|
||||
// genType & position
|
||||
//)
|
||||
//{
|
||||
// typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||
//
|
||||
// genType edge1 = vert1 - vert0;
|
||||
// genType edge2 = vert2 - vert0;
|
||||
//
|
||||
// genType pvec = cross(dir, edge2);
|
||||
//
|
||||
// float det = dot(edge1, pvec);
|
||||
// if(det < Epsilon)
|
||||
// return false;
|
||||
//
|
||||
// genType tvec = orig - vert0;
|
||||
//
|
||||
// position.y = dot(tvec, pvec);
|
||||
// if (position.y < typename genType::value_type(0) || position.y > det)
|
||||
// return typename genType::value_type(0);
|
||||
//
|
||||
// genType qvec = cross(tvec, edge1);
|
||||
//
|
||||
// position.z = dot(dir, qvec);
|
||||
// if (position.z < typename genType::value_type(0) || position.y + position.z > det)
|
||||
// return typename genType::value_type(0);
|
||||
//
|
||||
// position.x = dot(edge2, qvec);
|
||||
// position *= typename genType::value_type(1) / det;
|
||||
//
|
||||
// return typename genType::value_type(1);
|
||||
//}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool intersectLineTriangle
|
||||
(
|
||||
genType const & orig, genType const & dir,
|
||||
genType const & vert0, genType const & vert1, genType const & vert2,
|
||||
genType & position
|
||||
)
|
||||
{
|
||||
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||
|
||||
genType edge1 = vert1 - vert0;
|
||||
genType edge2 = vert2 - vert0;
|
||||
|
||||
genType pvec = cross(dir, edge2);
|
||||
|
||||
float det = dot(edge1, pvec);
|
||||
|
||||
if (det > -Epsilon && det < Epsilon)
|
||||
return false;
|
||||
float inv_det = typename genType::value_type(1) / det;
|
||||
|
||||
genType tvec = orig - vert0;
|
||||
|
||||
position.y = dot(tvec, pvec) * inv_det;
|
||||
if (position.y < typename genType::value_type(0) || position.y > typename genType::value_type(1))
|
||||
return false;
|
||||
|
||||
genType qvec = cross(tvec, edge1);
|
||||
|
||||
position.z = dot(dir, qvec) * inv_det;
|
||||
if (position.z < typename genType::value_type(0) || position.y + position.z > typename genType::value_type(1))
|
||||
return false;
|
||||
|
||||
position.x = dot(edge2, qvec) * inv_det;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool intersectRaySphere
|
||||
(
|
||||
genType const & rayStarting, genType const & rayDirection,
|
||||
genType const & sphereCenter, typename genType::value_type sphereRadius,
|
||||
genType & position, genType & normal
|
||||
)
|
||||
{
|
||||
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 b = typename genType::value_type(2) * dot(rayStarting, rayDirection);
|
||||
typename genType::value_type c = dot(rayStarting, rayStarting) - sphereRadius * sphereRadius;
|
||||
typename genType::value_type d = b * b - typename genType::value_type(4) * a * c;
|
||||
typename genType::value_type e = sqrt(d);
|
||||
typename genType::value_type x1 = (-b - e) / (typename genType::value_type(2) * a);
|
||||
typename genType::value_type x2 = (-b + e) / (typename genType::value_type(2) * a);
|
||||
|
||||
if(x1 > Epsilon)
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool intersectRayTriangle
|
||||
(
|
||||
genType const & orig, genType const & dir,
|
||||
genType const & v0, genType const & v1, genType const & v2,
|
||||
genType & baryPosition
|
||||
)
|
||||
{
|
||||
position = rayStarting + rayDirection * sphereRadius;
|
||||
normal = (position - sphereCenter) / sphereRadius;
|
||||
genType e1 = v1 - v0;
|
||||
genType e2 = v2 - v0;
|
||||
|
||||
genType p = glm::cross(dir, e2);
|
||||
|
||||
typename genType::value_type a = glm::dot(e1, p);
|
||||
|
||||
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||
if(a < Epsilon)
|
||||
return false;
|
||||
|
||||
typename genType::value_type f = typename genType::value_type(1.0f) / a;
|
||||
|
||||
genType s = orig - v0;
|
||||
baryPosition.x = f * glm::dot(s, p);
|
||||
if(baryPosition.x < typename genType::value_type(0.0f))
|
||||
return false;
|
||||
if(baryPosition.x > typename genType::value_type(1.0f))
|
||||
return false;
|
||||
|
||||
genType q = glm::cross(s, e1);
|
||||
baryPosition.y = f * glm::dot(dir, q);
|
||||
if(baryPosition.y < typename genType::value_type(0.0f))
|
||||
return false;
|
||||
if(baryPosition.y + baryPosition.x > typename genType::value_type(1.0f))
|
||||
return false;
|
||||
|
||||
baryPosition.z = f * glm::dot(e2, q);
|
||||
|
||||
return baryPosition.z >= typename genType::value_type(0.0f);
|
||||
}
|
||||
|
||||
//template <typename genType>
|
||||
//GLM_FUNC_QUALIFIER bool intersectRayTriangle
|
||||
//(
|
||||
// genType const & orig, genType const & dir,
|
||||
// genType const & vert0, genType const & vert1, genType const & vert2,
|
||||
// genType & position
|
||||
//)
|
||||
//{
|
||||
// typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||
//
|
||||
// genType edge1 = vert1 - vert0;
|
||||
// genType edge2 = vert2 - vert0;
|
||||
//
|
||||
// genType pvec = cross(dir, edge2);
|
||||
//
|
||||
// float det = dot(edge1, pvec);
|
||||
// if(det < Epsilon)
|
||||
// return false;
|
||||
//
|
||||
// genType tvec = orig - vert0;
|
||||
//
|
||||
// position.y = dot(tvec, pvec);
|
||||
// if (position.y < typename genType::value_type(0) || position.y > det)
|
||||
// return typename genType::value_type(0);
|
||||
//
|
||||
// genType qvec = cross(tvec, edge1);
|
||||
//
|
||||
// position.z = dot(dir, qvec);
|
||||
// if (position.z < typename genType::value_type(0) || position.y + position.z > det)
|
||||
// return typename genType::value_type(0);
|
||||
//
|
||||
// position.x = dot(edge2, qvec);
|
||||
// position *= typename genType::value_type(1) / det;
|
||||
//
|
||||
// return typename genType::value_type(1);
|
||||
//}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool intersectLineTriangle
|
||||
(
|
||||
genType const & orig, genType const & dir,
|
||||
genType const & vert0, genType const & vert1, genType const & vert2,
|
||||
genType & position
|
||||
)
|
||||
{
|
||||
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||
|
||||
genType edge1 = vert1 - vert0;
|
||||
genType edge2 = vert2 - vert0;
|
||||
|
||||
genType pvec = cross(dir, edge2);
|
||||
|
||||
float det = dot(edge1, pvec);
|
||||
|
||||
if (det > -Epsilon && det < Epsilon)
|
||||
return false;
|
||||
float inv_det = typename genType::value_type(1) / det;
|
||||
|
||||
genType tvec = orig - vert0;
|
||||
|
||||
position.y = dot(tvec, pvec) * inv_det;
|
||||
if (position.y < typename genType::value_type(0) || position.y > typename genType::value_type(1))
|
||||
return false;
|
||||
|
||||
genType qvec = cross(tvec, edge1);
|
||||
|
||||
position.z = dot(dir, qvec) * inv_det;
|
||||
if (position.z < typename genType::value_type(0) || position.y + position.z > typename genType::value_type(1))
|
||||
return false;
|
||||
|
||||
position.x = dot(edge2, qvec) * inv_det;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(x2 > Epsilon)
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool intersectRaySphere
|
||||
(
|
||||
genType const & rayStarting, genType const & rayDirection,
|
||||
genType const & sphereCenter, typename genType::value_type sphereRadius,
|
||||
genType & position, genType & normal
|
||||
)
|
||||
{
|
||||
position = rayStarting + rayDirection * sphereRadius;
|
||||
normal = (position - sphereCenter) / sphereRadius;
|
||||
return true;
|
||||
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 b = typename genType::value_type(2) * dot(rayStarting, rayDirection);
|
||||
typename genType::value_type c = dot(rayStarting, rayStarting) - sphereRadius * sphereRadius;
|
||||
typename genType::value_type d = b * b - typename genType::value_type(4) * a * c;
|
||||
typename genType::value_type e = sqrt(d);
|
||||
typename genType::value_type x1 = (-b - e) / (typename genType::value_type(2) * a);
|
||||
typename genType::value_type x2 = (-b + e) / (typename genType::value_type(2) * a);
|
||||
|
||||
if(x1 > Epsilon)
|
||||
{
|
||||
position = rayStarting + rayDirection * sphereRadius;
|
||||
normal = (position - sphereCenter) / sphereRadius;
|
||||
return true;
|
||||
}
|
||||
else if(x2 > Epsilon)
|
||||
{
|
||||
position = rayStarting + rayDirection * sphereRadius;
|
||||
normal = (position - sphereCenter) / sphereRadius;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool intersectLineSphere
|
||||
(
|
||||
genType const & point0, genType const & point1,
|
||||
genType const & center, typename genType::value_type radius,
|
||||
genType & position, genType & normal
|
||||
)
|
||||
{
|
||||
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||
|
||||
genType dir = point1 - point0;
|
||||
typename genType::value_type a = dot(dir, dir);
|
||||
typename genType::value_type b = typename genType::value_type(2) * dot(center, dir);
|
||||
typename genType::value_type c = dot(center, center) - radius * radius;
|
||||
typename genType::value_type d = b * b - typename genType::value_type(4) * a * c;
|
||||
typename genType::value_type e = sqrt(d);
|
||||
typename genType::value_type x1 = (-b - e) / (typename genType::value_type(2) * a);
|
||||
typename genType::value_type x2 = (-b + e) / (typename genType::value_type(2) * a);
|
||||
|
||||
if(x1 > Epsilon)
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool intersectLineSphere
|
||||
(
|
||||
genType const & point0, genType const & point1,
|
||||
genType const & center, typename genType::value_type radius,
|
||||
genType & position, genType & normal
|
||||
)
|
||||
{
|
||||
position = center + dir * radius;
|
||||
normal = (position - center) / radius;
|
||||
return true;
|
||||
}
|
||||
else if(x2 > Epsilon)
|
||||
{
|
||||
position = center + dir * radius;
|
||||
normal = (position - center) / radius;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||
|
||||
genType dir = point1 - point0;
|
||||
typename genType::value_type a = dot(dir, dir);
|
||||
typename genType::value_type b = typename genType::value_type(2) * dot(center, dir);
|
||||
typename genType::value_type c = dot(center, center) - radius * radius;
|
||||
typename genType::value_type d = b * b - typename genType::value_type(4) * a * c;
|
||||
typename genType::value_type e = sqrt(d);
|
||||
typename genType::value_type x1 = (-b - e) / (typename genType::value_type(2) * a);
|
||||
typename genType::value_type x2 = (-b + e) / (typename genType::value_type(2) * a);
|
||||
|
||||
if(x1 > Epsilon)
|
||||
{
|
||||
position = center + dir * radius;
|
||||
normal = (position - center) / radius;
|
||||
return true;
|
||||
}
|
||||
else if(x2 > Epsilon)
|
||||
{
|
||||
position = center + dir * radius;
|
||||
normal = (position - center) / radius;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,82 +7,20 @@
|
||||
// File : glm/gtx/log_base.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
#include "../core/_vectorize.hpp"
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType log(
|
||||
genType const & x,
|
||||
genType const & base)
|
||||
namespace glm
|
||||
{
|
||||
assert(x != genType(0));
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType log(
|
||||
genType const & x,
|
||||
genType const & base)
|
||||
{
|
||||
assert(x != genType(0));
|
||||
|
||||
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));
|
||||
}
|
||||
return glm::log(x) / glm::log(base);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC_SCA(log)
|
||||
VECTORIZE_VEC_VEC(log)
|
||||
}//namespace glm
|
||||
|
@ -7,34 +7,38 @@
|
||||
// File : glm/gtx/matrix_cross_product.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> matrixCross3(
|
||||
detail::tvec3<T> const & x)
|
||||
namespace glm
|
||||
{
|
||||
detail::tmat3x3<T> Result(T(0));
|
||||
Result[0][1] = x.z;
|
||||
Result[1][0] = -x.z;
|
||||
Result[0][2] = -x.y;
|
||||
Result[2][0] = x.y;
|
||||
Result[1][2] = x.x;
|
||||
Result[2][1] = -x.x;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> matrixCross3
|
||||
(
|
||||
detail::tvec3<T> const & x
|
||||
)
|
||||
{
|
||||
detail::tmat3x3<T> Result(T(0));
|
||||
Result[0][1] = x.z;
|
||||
Result[1][0] = -x.z;
|
||||
Result[0][2] = -x.y;
|
||||
Result[2][0] = x.y;
|
||||
Result[1][2] = x.x;
|
||||
Result[2][1] = -x.x;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> matrixCross4(
|
||||
detail::tvec3<T> const & x)
|
||||
{
|
||||
detail::tmat4x4<T> Result(T(0));
|
||||
Result[0][1] = x.z;
|
||||
Result[1][0] = -x.z;
|
||||
Result[0][2] = -x.y;
|
||||
Result[2][0] = x.y;
|
||||
Result[1][2] = x.x;
|
||||
Result[2][1] = -x.x;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> matrixCross4
|
||||
(
|
||||
detail::tvec3<T> const & x
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T> Result(T(0));
|
||||
Result[0][1] = x.z;
|
||||
Result[1][0] = -x.z;
|
||||
Result[0][2] = -x.y;
|
||||
Result[2][0] = x.y;
|
||||
Result[1][2] = x.x;
|
||||
Result[2][1] = -x.x;
|
||||
return Result;
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
@ -7,107 +7,112 @@
|
||||
// File : glm/gtx/matrix_interpolation.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER void axisAngle(
|
||||
detail::tmat4x4<T> const & mat,
|
||||
detail::tvec3<T> & axis,
|
||||
T & angle)
|
||||
namespace glm
|
||||
{
|
||||
T epsilon = (T)0.01;
|
||||
T epsilon2 = (T)0.1;
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER void axisAngle
|
||||
(
|
||||
detail::tmat4x4<T> const & mat,
|
||||
detail::tvec3<T> & axis,
|
||||
T & angle
|
||||
)
|
||||
{
|
||||
T epsilon = (T)0.01;
|
||||
T epsilon2 = (T)0.1;
|
||||
|
||||
if ((fabs(mat[1][0] - mat[0][1]) < epsilon) && (fabs(mat[2][0] - mat[0][2]) < epsilon) && (fabs(mat[2][1] - mat[1][2]) < epsilon)) {
|
||||
if ((fabs(mat[1][0] + mat[0][1]) < epsilon2) && (fabs(mat[2][0] + mat[0][2]) < epsilon2) && (fabs(mat[2][1] + mat[1][2]) < epsilon2) && (fabs(mat[0][0] + mat[1][1] + mat[2][2] - (T)3.0) < epsilon2)) {
|
||||
angle = (T)0.0;
|
||||
axis.x = (T)1.0;
|
||||
axis.y = (T)0.0;
|
||||
axis.z = (T)0.0;
|
||||
return;
|
||||
}
|
||||
angle = T(3.1415926535897932384626433832795);
|
||||
T xx = (mat[0][0] + (T)1.0) / (T)2.0;
|
||||
T yy = (mat[1][1] + (T)1.0) / (T)2.0;
|
||||
T zz = (mat[2][2] + (T)1.0) / (T)2.0;
|
||||
T xy = (mat[1][0] + mat[0][1]) / (T)4.0;
|
||||
T xz = (mat[2][0] + mat[0][2]) / (T)4.0;
|
||||
T yz = (mat[2][1] + mat[1][2]) / (T)4.0;
|
||||
if ((xx > yy) && (xx > zz)) {
|
||||
if (xx < epsilon) {
|
||||
axis.x = (T)0.0;
|
||||
axis.y = (T)0.7071;
|
||||
axis.z = (T)0.7071;
|
||||
} else {
|
||||
axis.x = sqrt(xx);
|
||||
axis.y = xy / axis.x;
|
||||
axis.z = xz / axis.x;
|
||||
}
|
||||
} else if (yy > zz) {
|
||||
if (yy < epsilon) {
|
||||
axis.x = (T)0.7071;
|
||||
axis.y = (T)0.0;
|
||||
axis.z = (T)0.7071;
|
||||
} else {
|
||||
axis.y = sqrt(yy);
|
||||
axis.x = xy / axis.y;
|
||||
axis.z = yz / axis.y;
|
||||
}
|
||||
} else {
|
||||
if (zz < epsilon) {
|
||||
axis.x = (T)0.7071;
|
||||
axis.y = (T)0.7071;
|
||||
axis.z = (T)0.0;
|
||||
} else {
|
||||
axis.z = sqrt(zz);
|
||||
axis.x = xz / axis.z;
|
||||
axis.y = yz / axis.z;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1]));
|
||||
if (glm::abs(s) < T(0.001))
|
||||
s = (T)1.0;
|
||||
angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) / (T)2.0);
|
||||
axis.x = (mat[1][2] - mat[2][1]) / s;
|
||||
axis.y = (mat[2][0] - mat[0][2]) / s;
|
||||
axis.z = (mat[0][1] - mat[1][0]) / s;
|
||||
}
|
||||
if ((fabs(mat[1][0] - mat[0][1]) < epsilon) && (fabs(mat[2][0] - mat[0][2]) < epsilon) && (fabs(mat[2][1] - mat[1][2]) < epsilon)) {
|
||||
if ((fabs(mat[1][0] + mat[0][1]) < epsilon2) && (fabs(mat[2][0] + mat[0][2]) < epsilon2) && (fabs(mat[2][1] + mat[1][2]) < epsilon2) && (fabs(mat[0][0] + mat[1][1] + mat[2][2] - (T)3.0) < epsilon2)) {
|
||||
angle = (T)0.0;
|
||||
axis.x = (T)1.0;
|
||||
axis.y = (T)0.0;
|
||||
axis.z = (T)0.0;
|
||||
return;
|
||||
}
|
||||
angle = T(3.1415926535897932384626433832795);
|
||||
T xx = (mat[0][0] + (T)1.0) / (T)2.0;
|
||||
T yy = (mat[1][1] + (T)1.0) / (T)2.0;
|
||||
T zz = (mat[2][2] + (T)1.0) / (T)2.0;
|
||||
T xy = (mat[1][0] + mat[0][1]) / (T)4.0;
|
||||
T xz = (mat[2][0] + mat[0][2]) / (T)4.0;
|
||||
T yz = (mat[2][1] + mat[1][2]) / (T)4.0;
|
||||
if ((xx > yy) && (xx > zz)) {
|
||||
if (xx < epsilon) {
|
||||
axis.x = (T)0.0;
|
||||
axis.y = (T)0.7071;
|
||||
axis.z = (T)0.7071;
|
||||
} else {
|
||||
axis.x = sqrt(xx);
|
||||
axis.y = xy / axis.x;
|
||||
axis.z = xz / axis.x;
|
||||
}
|
||||
} else if (yy > zz) {
|
||||
if (yy < epsilon) {
|
||||
axis.x = (T)0.7071;
|
||||
axis.y = (T)0.0;
|
||||
axis.z = (T)0.7071;
|
||||
} else {
|
||||
axis.y = sqrt(yy);
|
||||
axis.x = xy / axis.y;
|
||||
axis.z = yz / axis.y;
|
||||
}
|
||||
} else {
|
||||
if (zz < epsilon) {
|
||||
axis.x = (T)0.7071;
|
||||
axis.y = (T)0.7071;
|
||||
axis.z = (T)0.0;
|
||||
} else {
|
||||
axis.z = sqrt(zz);
|
||||
axis.x = xz / axis.z;
|
||||
axis.y = yz / axis.z;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1]));
|
||||
if (glm::abs(s) < T(0.001))
|
||||
s = (T)1.0;
|
||||
angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) / (T)2.0);
|
||||
axis.x = (mat[1][2] - mat[2][1]) / s;
|
||||
axis.y = (mat[2][0] - mat[0][2]) / s;
|
||||
axis.z = (mat[0][1] - mat[1][0]) / s;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> axisAngleMatrix(
|
||||
detail::tvec3<T> const & axis,
|
||||
T const angle)
|
||||
{
|
||||
T c = cos(angle);
|
||||
T s = sin(angle);
|
||||
T t = T(1) - c;
|
||||
detail::tvec3<T> n = normalize(axis);
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> axisAngleMatrix
|
||||
(
|
||||
detail::tvec3<T> const & axis,
|
||||
T const angle
|
||||
)
|
||||
{
|
||||
T c = cos(angle);
|
||||
T s = sin(angle);
|
||||
T t = T(1) - c;
|
||||
detail::tvec3<T> n = normalize(axis);
|
||||
|
||||
return detail::tmat4x4<T>(
|
||||
t * n.x * n.x + c, t * n.x * n.y + n.z * s, t * n.x * n.z - n.y * s, T(0),
|
||||
t * n.x * n.y - n.z * s, t * n.y * n.y + c, t * n.y * n.z + n.x * s, 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)
|
||||
);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> interpolate(
|
||||
detail::tmat4x4<T> const & m1,
|
||||
detail::tmat4x4<T> const & m2,
|
||||
T const delta)
|
||||
{
|
||||
detail::tmat4x4<T> dltRotation = m2 * transpose(m1);
|
||||
detail::tvec3<T> dltAxis;
|
||||
T dltAngle;
|
||||
axisAngle(dltRotation, dltAxis, dltAngle);
|
||||
detail::tmat4x4<T> out = axisAngleMatrix(dltAxis, dltAngle * delta) * rotationMatrix(m1);
|
||||
out[3][0] = m1[3][0] + delta * (m2[3][0] - m1[3][0]);
|
||||
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]);
|
||||
return out;
|
||||
}
|
||||
return detail::tmat4x4<T>(
|
||||
t * n.x * n.x + c, t * n.x * n.y + n.z * s, t * n.x * n.z - n.y * s, T(0),
|
||||
t * n.x * n.y - n.z * s, t * n.y * n.y + c, t * n.y * n.z + n.x * s, 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)
|
||||
);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> interpolate
|
||||
(
|
||||
detail::tmat4x4<T> const & m1,
|
||||
detail::tmat4x4<T> const & m2,
|
||||
T const delta
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<T> dltRotation = m2 * transpose(m1);
|
||||
detail::tvec3<T> dltAxis;
|
||||
T dltAngle;
|
||||
axisAngle(dltRotation, dltAxis, dltAngle);
|
||||
detail::tmat4x4<T> out = axisAngleMatrix(dltAxis, dltAngle * delta) * rotationMatrix(m1);
|
||||
out[3][0] = m1[3][0] + delta * (m2[3][0] - m1[3][0]);
|
||||
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]);
|
||||
return out;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -55,85 +55,85 @@ namespace glm
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat2x2<T> rowMajor2(
|
||||
const detail::tvec2<T>& v1,
|
||||
const detail::tvec2<T>& v2);
|
||||
detail::tvec2<T> const & v1,
|
||||
detail::tvec2<T> const & v2);
|
||||
|
||||
//! Build a row major matrix from other matrix.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat2x2<T> rowMajor2(
|
||||
const detail::tmat2x2<T>& m);
|
||||
detail::tmat2x2<T> const & m);
|
||||
|
||||
//! Build a row major matrix from row vectors.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat3x3<T> rowMajor3(
|
||||
const detail::tvec3<T>& v1,
|
||||
const detail::tvec3<T>& v2,
|
||||
const detail::tvec3<T>& v3);
|
||||
detail::tvec3<T> const & v1,
|
||||
detail::tvec3<T> const & v2,
|
||||
detail::tvec3<T> const & v3);
|
||||
|
||||
//! Build a row major matrix from other matrix.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat3x3<T> rowMajor3(
|
||||
const detail::tmat3x3<T>& m);
|
||||
detail::tmat3x3<T> const & m);
|
||||
|
||||
//! Build a row major matrix from row vectors.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> rowMajor4(
|
||||
const detail::tvec4<T>& v1,
|
||||
const detail::tvec4<T>& v2,
|
||||
const detail::tvec4<T>& v3,
|
||||
const detail::tvec4<T>& v4);
|
||||
detail::tvec4<T> const & v1,
|
||||
detail::tvec4<T> const & v2,
|
||||
detail::tvec4<T> const & v3,
|
||||
detail::tvec4<T> const & v4);
|
||||
|
||||
//! Build a row major matrix from other matrix.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> rowMajor4(
|
||||
const detail::tmat4x4<T>& m);
|
||||
detail::tmat4x4<T> const & m);
|
||||
|
||||
//! Build a column major matrix from column vectors.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat2x2<T> colMajor2(
|
||||
const detail::tvec2<T>& v1,
|
||||
const detail::tvec2<T>& v2);
|
||||
detail::tvec2<T> const & v1,
|
||||
detail::tvec2<T> const & v2);
|
||||
|
||||
//! Build a column major matrix from other matrix.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat2x2<T> colMajor2(
|
||||
const detail::tmat2x2<T>& m);
|
||||
detail::tmat2x2<T> const & m);
|
||||
|
||||
//! Build a column major matrix from column vectors.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat3x3<T> colMajor3(
|
||||
const detail::tvec3<T>& v1,
|
||||
const detail::tvec3<T>& v2,
|
||||
const detail::tvec3<T>& v3);
|
||||
detail::tvec3<T> const & v1,
|
||||
detail::tvec3<T> const & v2,
|
||||
detail::tvec3<T> const & v3);
|
||||
|
||||
//! Build a column major matrix from other matrix.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat3x3<T> colMajor3(
|
||||
const detail::tmat3x3<T>& m);
|
||||
detail::tmat3x3<T> const & m);
|
||||
|
||||
//! Build a column major matrix from column vectors.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> colMajor4(
|
||||
const detail::tvec4<T>& v1,
|
||||
const detail::tvec4<T>& v2,
|
||||
const detail::tvec4<T>& v3,
|
||||
const detail::tvec4<T>& v4);
|
||||
detail::tvec4<T> const & v1,
|
||||
detail::tvec4<T> const & v2,
|
||||
detail::tvec4<T> const & v3,
|
||||
detail::tvec4<T> const & v4);
|
||||
|
||||
//! Build a column major matrix from other matrix.
|
||||
//! From GLM_GTX_matrix_major_storage extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> colMajor4(
|
||||
const detail::tmat4x4<T>& m);
|
||||
detail::tmat4x4<T> const & m);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
@ -7,166 +7,167 @@
|
||||
// File : glm/gtx/matrix_major_storage.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2(
|
||||
const detail::tvec2<T>& v1,
|
||||
const detail::tvec2<T>& v2)
|
||||
namespace glm
|
||||
{
|
||||
detail::tmat2x2<T> Result;
|
||||
Result[0][0] = v1.x;
|
||||
Result[1][0] = v1.y;
|
||||
Result[0][1] = v2.x;
|
||||
Result[1][1] = v2.y;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2
|
||||
(
|
||||
detail::tvec2<T> const & v1,
|
||||
detail::tvec2<T> const & v2
|
||||
)
|
||||
{
|
||||
detail::tmat2x2<T> Result;
|
||||
Result[0][0] = v1.x;
|
||||
Result[1][0] = v1.y;
|
||||
Result[0][1] = v2.x;
|
||||
Result[1][1] = v2.y;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2(
|
||||
const detail::tmat2x2<T>& m)
|
||||
{
|
||||
detail::tmat2x2<T> Result;
|
||||
Result[0][0] = m[0][0];
|
||||
Result[0][1] = m[1][0];
|
||||
Result[1][0] = m[0][1];
|
||||
Result[1][1] = m[1][1];
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2(
|
||||
const detail::tmat2x2<T>& m)
|
||||
{
|
||||
detail::tmat2x2<T> Result;
|
||||
Result[0][0] = m[0][0];
|
||||
Result[0][1] = m[1][0];
|
||||
Result[1][0] = m[0][1];
|
||||
Result[1][1] = m[1][1];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
|
||||
const detail::tvec3<T>& v1,
|
||||
const detail::tvec3<T>& v2,
|
||||
const detail::tvec3<T>& v3)
|
||||
{
|
||||
detail::tmat3x3<T> Result;
|
||||
Result[0][0] = v1.x;
|
||||
Result[1][0] = v1.y;
|
||||
Result[2][0] = v1.z;
|
||||
Result[0][1] = v2.x;
|
||||
Result[1][1] = v2.y;
|
||||
Result[2][1] = v2.z;
|
||||
Result[0][2] = v3.x;
|
||||
Result[1][2] = v3.y;
|
||||
Result[2][2] = v3.z;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
|
||||
const detail::tvec3<T>& v1,
|
||||
const detail::tvec3<T>& v2,
|
||||
const detail::tvec3<T>& v3)
|
||||
{
|
||||
detail::tmat3x3<T> Result;
|
||||
Result[0][0] = v1.x;
|
||||
Result[1][0] = v1.y;
|
||||
Result[2][0] = v1.z;
|
||||
Result[0][1] = v2.x;
|
||||
Result[1][1] = v2.y;
|
||||
Result[2][1] = v2.z;
|
||||
Result[0][2] = v3.x;
|
||||
Result[1][2] = v3.y;
|
||||
Result[2][2] = v3.z;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
|
||||
const detail::tmat3x3<T>& m)
|
||||
{
|
||||
detail::tmat3x3<T> Result;
|
||||
Result[0][0] = m[0][0];
|
||||
Result[0][1] = m[1][0];
|
||||
Result[0][2] = m[2][0];
|
||||
Result[1][0] = m[0][1];
|
||||
Result[1][1] = m[1][1];
|
||||
Result[1][2] = m[2][1];
|
||||
Result[2][0] = m[0][2];
|
||||
Result[2][1] = m[1][2];
|
||||
Result[2][2] = m[2][2];
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
|
||||
const detail::tmat3x3<T>& m)
|
||||
{
|
||||
detail::tmat3x3<T> Result;
|
||||
Result[0][0] = m[0][0];
|
||||
Result[0][1] = m[1][0];
|
||||
Result[0][2] = m[2][0];
|
||||
Result[1][0] = m[0][1];
|
||||
Result[1][1] = m[1][1];
|
||||
Result[1][2] = m[2][1];
|
||||
Result[2][0] = m[0][2];
|
||||
Result[2][1] = m[1][2];
|
||||
Result[2][2] = m[2][2];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
|
||||
const detail::tvec4<T>& v1,
|
||||
const detail::tvec4<T>& v2,
|
||||
const detail::tvec4<T>& v3,
|
||||
const detail::tvec4<T>& v4)
|
||||
{
|
||||
detail::tmat4x4<T> Result;
|
||||
Result[0][0] = v1.x;
|
||||
Result[1][0] = v1.y;
|
||||
Result[2][0] = v1.z;
|
||||
Result[3][0] = v1.w;
|
||||
Result[0][1] = v2.x;
|
||||
Result[1][1] = v2.y;
|
||||
Result[2][1] = v2.z;
|
||||
Result[3][1] = v2.w;
|
||||
Result[0][2] = v3.x;
|
||||
Result[1][2] = v3.y;
|
||||
Result[2][2] = v3.z;
|
||||
Result[3][2] = v3.w;
|
||||
Result[0][3] = v4.x;
|
||||
Result[1][3] = v4.y;
|
||||
Result[2][3] = v4.z;
|
||||
Result[3][3] = v4.w;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
|
||||
const detail::tvec4<T>& v1,
|
||||
const detail::tvec4<T>& v2,
|
||||
const detail::tvec4<T>& v3,
|
||||
const detail::tvec4<T>& v4)
|
||||
{
|
||||
detail::tmat4x4<T> Result;
|
||||
Result[0][0] = v1.x;
|
||||
Result[1][0] = v1.y;
|
||||
Result[2][0] = v1.z;
|
||||
Result[3][0] = v1.w;
|
||||
Result[0][1] = v2.x;
|
||||
Result[1][1] = v2.y;
|
||||
Result[2][1] = v2.z;
|
||||
Result[3][1] = v2.w;
|
||||
Result[0][2] = v3.x;
|
||||
Result[1][2] = v3.y;
|
||||
Result[2][2] = v3.z;
|
||||
Result[3][2] = v3.w;
|
||||
Result[0][3] = v4.x;
|
||||
Result[1][3] = v4.y;
|
||||
Result[2][3] = v4.z;
|
||||
Result[3][3] = v4.w;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
|
||||
const detail::tmat4x4<T>& m)
|
||||
{
|
||||
detail::tmat4x4<T> Result;
|
||||
Result[0][0] = m[0][0];
|
||||
Result[0][1] = m[1][0];
|
||||
Result[0][2] = m[2][0];
|
||||
Result[0][3] = m[3][0];
|
||||
Result[1][0] = m[0][1];
|
||||
Result[1][1] = m[1][1];
|
||||
Result[1][2] = m[2][1];
|
||||
Result[1][3] = m[3][1];
|
||||
Result[2][0] = m[0][2];
|
||||
Result[2][1] = m[1][2];
|
||||
Result[2][2] = m[2][2];
|
||||
Result[2][3] = m[3][2];
|
||||
Result[3][0] = m[0][3];
|
||||
Result[3][1] = m[1][3];
|
||||
Result[3][2] = m[2][3];
|
||||
Result[3][3] = m[3][3];
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
|
||||
const detail::tmat4x4<T>& m)
|
||||
{
|
||||
detail::tmat4x4<T> Result;
|
||||
Result[0][0] = m[0][0];
|
||||
Result[0][1] = m[1][0];
|
||||
Result[0][2] = m[2][0];
|
||||
Result[0][3] = m[3][0];
|
||||
Result[1][0] = m[0][1];
|
||||
Result[1][1] = m[1][1];
|
||||
Result[1][2] = m[2][1];
|
||||
Result[1][3] = m[3][1];
|
||||
Result[2][0] = m[0][2];
|
||||
Result[2][1] = m[1][2];
|
||||
Result[2][2] = m[2][2];
|
||||
Result[2][3] = m[3][2];
|
||||
Result[3][0] = m[0][3];
|
||||
Result[3][1] = m[1][3];
|
||||
Result[3][2] = m[2][3];
|
||||
Result[3][3] = m[3][3];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2(
|
||||
const detail::tvec2<T>& v1,
|
||||
const detail::tvec2<T>& v2)
|
||||
{
|
||||
return detail::tmat2x2<T>(v1, v2);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2(
|
||||
const detail::tvec2<T>& v1,
|
||||
const detail::tvec2<T>& v2)
|
||||
{
|
||||
return detail::tmat2x2<T>(v1, v2);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2(
|
||||
const detail::tmat2x2<T>& m)
|
||||
{
|
||||
return detail::tmat2x2<T>(m);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2(
|
||||
const detail::tmat2x2<T>& m)
|
||||
{
|
||||
return detail::tmat2x2<T>(m);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3(
|
||||
const detail::tvec3<T>& v1,
|
||||
const detail::tvec3<T>& v2,
|
||||
const detail::tvec3<T>& v3)
|
||||
{
|
||||
return detail::tmat3x3<T>(v1, v2, v3);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3(
|
||||
const detail::tvec3<T>& v1,
|
||||
const detail::tvec3<T>& v2,
|
||||
const detail::tvec3<T>& v3)
|
||||
{
|
||||
return detail::tmat3x3<T>(v1, v2, v3);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3(
|
||||
const detail::tmat3x3<T>& m)
|
||||
{
|
||||
return detail::tmat3x3<T>(m);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3(
|
||||
const detail::tmat3x3<T>& m)
|
||||
{
|
||||
return detail::tmat3x3<T>(m);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4(
|
||||
const detail::tvec4<T>& v1,
|
||||
const detail::tvec4<T>& v2,
|
||||
const detail::tvec4<T>& v3,
|
||||
const detail::tvec4<T>& v4)
|
||||
{
|
||||
return detail::tmat4x4<T>(v1, v2, v3, v4);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4(
|
||||
const detail::tmat4x4<T>& m)
|
||||
{
|
||||
return detail::tmat4x4<T>(m);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4(
|
||||
const detail::tvec4<T>& v1,
|
||||
const detail::tvec4<T>& v2,
|
||||
const detail::tvec4<T>& v3,
|
||||
const detail::tvec4<T>& v4)
|
||||
{
|
||||
return detail::tmat4x4<T>(v1, v2, v3, v4);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4(
|
||||
const detail::tmat4x4<T>& m)
|
||||
{
|
||||
return detail::tmat4x4<T>(m);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,119 +7,118 @@
|
||||
// File : glm/gtx/matrix_operation.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> diagonal2x2
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
detail::tmat2x2<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> diagonal2x2
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat2x2<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x3<valType> diagonal2x3
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat2x3<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x3<valType> diagonal2x3
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat2x3<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x4<valType> diagonal2x4
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat2x4<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x4<valType> diagonal2x4
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat2x4<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x2<valType> diagonal3x2
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat3x2<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x2<valType> diagonal3x2
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat3x2<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> diagonal3x3
|
||||
(
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat3x3<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
Result[2][2] = v[2];
|
||||
return Result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> diagonal3x3
|
||||
(
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat3x3<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
Result[2][2] = v[2];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x4<valType> diagonal3x4
|
||||
(
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat3x4<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
Result[2][2] = v[2];
|
||||
return Result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x4<valType> diagonal3x4
|
||||
(
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat3x4<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
Result[2][2] = v[2];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> diagonal4x4
|
||||
(
|
||||
detail::tvec4<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
Result[2][2] = v[2];
|
||||
Result[3][3] = v[3];
|
||||
return Result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> diagonal4x4
|
||||
(
|
||||
detail::tvec4<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x4<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
Result[2][2] = v[2];
|
||||
Result[3][3] = v[3];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x3<valType> diagonal4x3
|
||||
(
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x3<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
Result[2][2] = v[2];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x2<valType> diagonal4x2
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x2<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x3<valType> diagonal4x3
|
||||
(
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x3<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
Result[2][2] = v[2];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x2<valType> diagonal4x2
|
||||
(
|
||||
detail::tvec2<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tmat4x2<valType> Result(valType(1));
|
||||
Result[0][0] = v[0];
|
||||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -56,57 +56,57 @@ namespace glm
|
||||
//! From GLM_GTX_matrix_query extension.
|
||||
template<typename T>
|
||||
bool isNull(
|
||||
const detail::tmat2x2<T>& m,
|
||||
const T epsilon = std::numeric_limits<T>::epsilon());
|
||||
detail::tmat2x2<T> const & m,
|
||||
T const & epsilon = std::numeric_limits<T>::epsilon());
|
||||
|
||||
//! Return if a matrix a null matrix.
|
||||
//! From GLM_GTX_matrix_query extension.
|
||||
template<typename T>
|
||||
bool isNull(
|
||||
const detail::tmat3x3<T>& m,
|
||||
const T epsilon = std::numeric_limits<T>::epsilon());
|
||||
detail::tmat3x3<T> const & m,
|
||||
T const & epsilon = std::numeric_limits<T>::epsilon());
|
||||
|
||||
//! Return if a matrix a null matrix.
|
||||
//! From GLM_GTX_matrix_query extension.
|
||||
template<typename T>
|
||||
bool isNull(
|
||||
const detail::tmat4x4<T>& m,
|
||||
const T epsilon = std::numeric_limits<T>::epsilon());
|
||||
detail::tmat4x4<T> const & m,
|
||||
T const & epsilon = std::numeric_limits<T>::epsilon());
|
||||
|
||||
//! Return if a matrix an identity matrix.
|
||||
//! From GLM_GTX_matrix_query extension.
|
||||
template<typename genType>
|
||||
bool isIdentity(
|
||||
const genType& m,
|
||||
const typename genType::value_type epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
genType const & m,
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
//! Return if a matrix a normalized matrix.
|
||||
//! From GLM_GTX_matrix_query extension.
|
||||
template<typename T>
|
||||
bool isNormalized(
|
||||
const detail::tmat2x2<T>& m,
|
||||
const T epsilon = std::numeric_limits<T>::epsilon());
|
||||
detail::tmat2x2<T> const & m,
|
||||
T const & epsilon = std::numeric_limits<T>::epsilon());
|
||||
|
||||
//! Return if a matrix a normalized matrix.
|
||||
//! From GLM_GTX_matrix_query extension.
|
||||
template<typename T>
|
||||
bool isNormalized(
|
||||
const detail::tmat3x3<T>& m,
|
||||
const T epsilon = std::numeric_limits<T>::epsilon());
|
||||
detail::tmat3x3<T> const & m,
|
||||
T const & epsilon = std::numeric_limits<T>::epsilon());
|
||||
|
||||
//! Return if a matrix a normalized matrix.
|
||||
//! From GLM_GTX_matrix_query extension.
|
||||
template<typename T>
|
||||
bool isNormalized(
|
||||
const detail::tmat4x4<T>& m,
|
||||
const T epsilon = std::numeric_limits<T>::epsilon());
|
||||
detail::tmat4x4<T> const & m,
|
||||
T const & epsilon = std::numeric_limits<T>::epsilon());
|
||||
|
||||
//! Return if a matrix an orthonormalized matrix.
|
||||
//! From GLM_GTX_matrix_query extension.
|
||||
template<typename genType>
|
||||
bool isOrthogonal(
|
||||
const genType& m,
|
||||
const typename genType::value_type epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
genType const & m,
|
||||
typename genType::value_type const & epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
@ -10,131 +10,145 @@
|
||||
// - GLM core
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNull(
|
||||
const detail::tmat2x2<T>& m,
|
||||
const T epsilon)
|
||||
namespace glm
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 2 ; ++i)
|
||||
result = isNull(m[i], epsilon);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNull(
|
||||
const detail::tmat3x3<T>& m,
|
||||
const T epsilon)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 3 ; ++i)
|
||||
result = isNull(m[i], epsilon);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNull(
|
||||
const detail::tmat4x4<T>& m,
|
||||
const T epsilon)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 4 ; ++i)
|
||||
result = isNull(m[i], epsilon);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isIdentity(
|
||||
const genType& m,
|
||||
const typename genType::value_type epsilon)
|
||||
{
|
||||
bool result = true;
|
||||
for(typename genType::value_type i = typename genType::value_type(0); result && i < genType::col_size(); ++i)
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNull
|
||||
(
|
||||
detail::tmat2x2<T> const & m,
|
||||
T const & epsilon)
|
||||
{
|
||||
for(typename genType::value_type j = typename genType::value_type(0); result && j < i ; ++j)
|
||||
result = abs(m[i][j]) <= epsilon;
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 2 ; ++i)
|
||||
result = isNull(m[i], epsilon);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNull
|
||||
(
|
||||
detail::tmat3x3<T> const & m,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 3 ; ++i)
|
||||
result = isNull(m[i], epsilon);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNull
|
||||
(
|
||||
detail::tmat4x4<T> const & m,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 4 ; ++i)
|
||||
result = isNull(m[i], epsilon);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isIdentity
|
||||
(
|
||||
genType const & m,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
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 j = typename genType::value_type(0); result && j < i ; ++j)
|
||||
result = abs(m[i][j]) <= epsilon;
|
||||
if(result)
|
||||
result = abs(m[i][i] - typename genType::value_type(1)) <= epsilon;
|
||||
for(typename genType::value_type j = i + typename genType::value_type(1); result && j < genType::row_size(); ++j)
|
||||
result = abs(m[i][j]) <= epsilon;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNormalized
|
||||
(
|
||||
detail::tmat2x2<T> const & m,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 2; ++i)
|
||||
result = isNormalized(m[i], epsilon);
|
||||
for(int i = 0; result && i < 2; ++i)
|
||||
{
|
||||
detail::tvec2<T> v;
|
||||
for(int j = 0; j < 2; ++j)
|
||||
v[j] = m[j][i];
|
||||
result = isNormalized(v, epsilon);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNormalized
|
||||
(
|
||||
detail::tmat3x3<T> const & m,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 3; ++i)
|
||||
result = isNormalized(m[i], epsilon);
|
||||
for(int i = 0; result && i < 3; ++i)
|
||||
{
|
||||
detail::tvec3<T> v;
|
||||
for(int j = 0; j < 3; ++j)
|
||||
v[j] = m[j][i];
|
||||
result = isNormalized(v, epsilon);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNormalized
|
||||
(
|
||||
detail::tmat4x4<T> const & m,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 4; ++i)
|
||||
result = isNormalized(m[i], epsilon);
|
||||
for(int i = 0; result && i < 4; ++i)
|
||||
{
|
||||
detail::tvec4<T> v;
|
||||
for(int j = 0; j < 4; ++j)
|
||||
v[j] = m[j][i];
|
||||
result = isNormalized(v, epsilon);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isOrthogonal
|
||||
(
|
||||
genType const & m,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < genType::col_size() - 1; ++i)
|
||||
for(int j= i + 1; result && j < genType::col_size(); ++j)
|
||||
result = areOrthogonal(m[i], m[j], epsilon);
|
||||
|
||||
if(result)
|
||||
result = abs(m[i][i] - typename genType::value_type(1)) <= epsilon;
|
||||
for(typename genType::value_type j = i + typename genType::value_type(1); result && j < genType::row_size(); ++j)
|
||||
result = abs(m[i][j]) <= epsilon;
|
||||
{
|
||||
genType tmp = transpose(m);
|
||||
for(int i = 0; result && i < genType::col_size() - 1 ; ++i)
|
||||
for(int j = i + 1; result && j < genType::col_size(); ++j)
|
||||
result = areOrthogonal(tmp[i], tmp[j], epsilon);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNormalized(
|
||||
const detail::tmat2x2<T>& m,
|
||||
const T epsilon)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 2; ++i)
|
||||
result = isNormalized(m[i], epsilon);
|
||||
for(int i = 0; result && i < 2; ++i)
|
||||
{
|
||||
detail::tvec2<T> v;
|
||||
for(int j = 0; j < 2; ++j)
|
||||
v[j] = m[j][i];
|
||||
result = isNormalized(v, epsilon);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNormalized(
|
||||
const detail::tmat3x3<T>& m,
|
||||
const T epsilon)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 3; ++i)
|
||||
result = isNormalized(m[i], epsilon);
|
||||
for(int i = 0; result && i < 3; ++i)
|
||||
{
|
||||
detail::tvec3<T> v;
|
||||
for(int j = 0; j < 3; ++j)
|
||||
v[j] = m[j][i];
|
||||
result = isNormalized(v, epsilon);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER bool isNormalized(
|
||||
const detail::tmat4x4<T>& m,
|
||||
const T epsilon)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < 4; ++i)
|
||||
result = isNormalized(m[i], epsilon);
|
||||
for(int i = 0; result && i < 4; ++i)
|
||||
{
|
||||
detail::tvec4<T> v;
|
||||
for(int j = 0; j < 4; ++j)
|
||||
v[j] = m[j][i];
|
||||
result = isNormalized(v, epsilon);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isOrthogonal(
|
||||
const genType& m,
|
||||
const typename genType::value_type epsilon)
|
||||
{
|
||||
bool result = true;
|
||||
for(int i = 0; result && i < genType::col_size() - 1; ++i)
|
||||
for(int j= i + 1; result && j < genType::col_size(); ++j)
|
||||
result = areOrthogonal(m[i], m[j], epsilon);
|
||||
|
||||
if(result)
|
||||
{
|
||||
genType tmp = transpose(m);
|
||||
for(int i = 0; result && i < genType::col_size() - 1 ; ++i)
|
||||
for(int j = i + 1; result && j < genType::col_size(); ++j)
|
||||
result = areOrthogonal(tmp[i], tmp[j], epsilon);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
@ -7,15 +7,16 @@
|
||||
// File : glm/gtx/mixed_product.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType mixedProduct(
|
||||
detail::tvec3<valType> const & v1,
|
||||
detail::tvec3<valType> const & v2,
|
||||
detail::tvec3<valType> const & v3)
|
||||
namespace glm
|
||||
{
|
||||
return dot(cross(v1, v2), v3);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType mixedProduct
|
||||
(
|
||||
detail::tvec3<valType> const & v1,
|
||||
detail::tvec3<valType> const & v2,
|
||||
detail::tvec3<valType> const & v3
|
||||
)
|
||||
{
|
||||
return dot(cross(v1, v2), v3);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -10,184 +10,111 @@
|
||||
// - GLM core
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
#include "../core/_vectorize.hpp"
|
||||
|
||||
//////////////////////
|
||||
// higherMultiple
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType higherMultiple
|
||||
(
|
||||
genType const & Source,
|
||||
genType const & Multiple
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
genType Tmp = Source % Multiple;
|
||||
return Tmp ? Source + Multiple - Tmp : Source;
|
||||
}
|
||||
//////////////////////
|
||||
// higherMultiple
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER detail::thalf higherMultiple
|
||||
(
|
||||
detail::thalf const & SourceH,
|
||||
detail::thalf const & MultipleH
|
||||
)
|
||||
{
|
||||
float Source = SourceH.toFloat();
|
||||
float Multiple = MultipleH.toFloat();
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType higherMultiple
|
||||
(
|
||||
genType const & Source,
|
||||
genType const & Multiple
|
||||
)
|
||||
{
|
||||
genType Tmp = Source % Multiple;
|
||||
return Tmp ? Source + Multiple - Tmp : Source;
|
||||
}
|
||||
|
||||
int Tmp = int(float(Source)) % int(Multiple);
|
||||
return detail::thalf(Tmp ? Source + Multiple - float(Tmp) : Source);
|
||||
}
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER detail::thalf higherMultiple
|
||||
(
|
||||
detail::thalf const & SourceH,
|
||||
detail::thalf const & MultipleH
|
||||
)
|
||||
{
|
||||
float Source = SourceH.toFloat();
|
||||
float Multiple = MultipleH.toFloat();
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER float higherMultiple
|
||||
(
|
||||
float const & Source,
|
||||
float const & Multiple
|
||||
)
|
||||
{
|
||||
int Tmp = int(Source) % int(Multiple);
|
||||
return Tmp ? Source + Multiple - float(Tmp) : Source;
|
||||
}
|
||||
int Tmp = int(float(Source)) % int(Multiple);
|
||||
return detail::thalf(Tmp ? Source + Multiple - float(Tmp) : Source);
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER double higherMultiple
|
||||
(
|
||||
double const & Source,
|
||||
double const & Multiple
|
||||
)
|
||||
{
|
||||
long Tmp = long(Source) % long(Multiple);
|
||||
return Tmp ? Source + Multiple - double(Tmp) : Source;
|
||||
}
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER float higherMultiple
|
||||
(
|
||||
float const & Source,
|
||||
float const & Multiple
|
||||
)
|
||||
{
|
||||
int Tmp = int(Source) % int(Multiple);
|
||||
return Tmp ? Source + Multiple - float(Tmp) : Source;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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 <>
|
||||
GLM_FUNC_QUALIFIER double higherMultiple
|
||||
(
|
||||
double const & Source,
|
||||
double const & Multiple
|
||||
)
|
||||
{
|
||||
long Tmp = long(Source) % long(Multiple);
|
||||
return Tmp ? Source + Multiple - double(Tmp) : Source;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> higherMultiple
|
||||
(
|
||||
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;
|
||||
}
|
||||
VECTORIZE_VEC_VEC(higherMultiple)
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> higherMultiple
|
||||
(
|
||||
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
|
||||
|
||||
//////////////////////
|
||||
// lowerMultiple
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType lowerMultiple
|
||||
(
|
||||
genType const & Source,
|
||||
genType const & Multiple
|
||||
)
|
||||
{
|
||||
genType Tmp = Source % Multiple;
|
||||
return Tmp ? Source - Tmp : Source;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType lowerMultiple
|
||||
(
|
||||
genType const & Source,
|
||||
genType const & Multiple
|
||||
)
|
||||
{
|
||||
genType Tmp = Source % Multiple;
|
||||
return Tmp ? Source - Tmp : Source;
|
||||
}
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER detail::thalf lowerMultiple
|
||||
(
|
||||
detail::thalf const & SourceH,
|
||||
detail::thalf const & MultipleH
|
||||
)
|
||||
{
|
||||
float Source = SourceH.toFloat();
|
||||
float Multiple = MultipleH.toFloat();
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER detail::thalf lowerMultiple
|
||||
(
|
||||
detail::thalf const & SourceH,
|
||||
detail::thalf const & MultipleH
|
||||
)
|
||||
{
|
||||
float Source = SourceH.toFloat();
|
||||
float Multiple = MultipleH.toFloat();
|
||||
int Tmp = int(float(Source)) % int(float(Multiple));
|
||||
return detail::thalf(Tmp ? Source - float(Tmp) : Source);
|
||||
}
|
||||
|
||||
int Tmp = int(float(Source)) % int(float(Multiple));
|
||||
return detail::thalf(Tmp ? Source - float(Tmp) : Source);
|
||||
}
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER float lowerMultiple
|
||||
(
|
||||
float const & Source,
|
||||
float const & Multiple
|
||||
)
|
||||
{
|
||||
int Tmp = int(Source) % int(Multiple);
|
||||
return Tmp ? Source - float(Tmp) : Source;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER float lowerMultiple
|
||||
(
|
||||
float const & Source,
|
||||
float const & Multiple
|
||||
)
|
||||
{
|
||||
int Tmp = int(Source) % int(Multiple);
|
||||
return Tmp ? Source - float(Tmp) : Source;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER double lowerMultiple
|
||||
(
|
||||
double const & Source,
|
||||
double const & Multiple
|
||||
)
|
||||
{
|
||||
long Tmp = long(Source) % long(Multiple);
|
||||
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;
|
||||
}
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER double lowerMultiple
|
||||
(
|
||||
double const & Source,
|
||||
double const & Multiple
|
||||
)
|
||||
{
|
||||
long Tmp = long(Source) % long(Multiple);
|
||||
return Tmp ? Source - double(Tmp) : Source;
|
||||
}
|
||||
|
||||
VECTORIZE_VEC_VEC(lowerMultiple)
|
||||
}//namespace glm
|
||||
|
@ -56,99 +56,73 @@ namespace glm
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T length2(
|
||||
const T x);
|
||||
T const & x);
|
||||
|
||||
//! Returns the squared length of x.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T length2(
|
||||
const detail::tvec2<T> & x);
|
||||
|
||||
//! 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);
|
||||
template <typename genType>
|
||||
typename genType::value_type length2(
|
||||
genType const & x);
|
||||
|
||||
//! Returns the squared length of x.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T length2(
|
||||
const detail::tquat<T>& q);
|
||||
detail::tquat<T> const & q);
|
||||
|
||||
//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T distance2(
|
||||
const T p0,
|
||||
const T p1);
|
||||
T const & p0,
|
||||
T 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::tvec2<T>& p0,
|
||||
const detail::tvec2<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::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);
|
||||
template <typename genType>
|
||||
typename genType::value_type distance2(
|
||||
genType const & p0,
|
||||
genType const & p1);
|
||||
|
||||
//! Returns the L1 norm between x and y.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T l1Norm(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<T>& y);
|
||||
detail::tvec3<T> const & x,
|
||||
detail::tvec3<T> const & y);
|
||||
|
||||
//! Returns the L1 norm of v.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T l1Norm(
|
||||
const detail::tvec3<T>& v);
|
||||
detail::tvec3<T> const & v);
|
||||
|
||||
//! Returns the L2 norm between x and y.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T l2Norm(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<T>& y);
|
||||
detail::tvec3<T> const & x,
|
||||
detail::tvec3<T> const & y);
|
||||
|
||||
//! Returns the L2 norm of v.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T l2Norm(
|
||||
const detail::tvec3<T>& x);
|
||||
detail::tvec3<T> const & x);
|
||||
|
||||
//! Returns the L norm between x and y.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T lxNorm(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<T>& y,
|
||||
detail::tvec3<T> const & x,
|
||||
detail::tvec3<T> const & y,
|
||||
unsigned int Depth);
|
||||
|
||||
//! Returns the L norm of v.
|
||||
//! From GLM_GTX_norm extension.
|
||||
template <typename T>
|
||||
T lxNorm(
|
||||
const detail::tvec3<T>& x,
|
||||
detail::tvec3<T> const & x,
|
||||
unsigned int Depth);
|
||||
|
||||
/// @}
|
||||
|
230
glm/gtx/norm.inl
230
glm/gtx/norm.inl
@ -7,120 +7,150 @@
|
||||
// File : glm/gtx/norm.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2(
|
||||
const T x)
|
||||
namespace glm
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2
|
||||
(
|
||||
T const & x
|
||||
)
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2(
|
||||
const detail::tvec2<T>& x)
|
||||
{
|
||||
return dot(x, x);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2
|
||||
(
|
||||
detail::tvec2<T> const & x
|
||||
)
|
||||
{
|
||||
return dot(x, x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2(
|
||||
const detail::tvec3<T>& x)
|
||||
{
|
||||
return dot(x, x);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2
|
||||
(
|
||||
detail::tvec3<T> const & x
|
||||
)
|
||||
{
|
||||
return dot(x, x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2(
|
||||
const detail::tvec4<T>& x)
|
||||
{
|
||||
return dot(x, x);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2
|
||||
(
|
||||
detail::tvec4<T> const & x
|
||||
)
|
||||
{
|
||||
return dot(x, x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2(
|
||||
const detail::tquat<T>& q)
|
||||
{
|
||||
return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T length2
|
||||
(
|
||||
detail::tquat<T> const & q
|
||||
)
|
||||
{
|
||||
return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T distance2(
|
||||
const T p0,
|
||||
const T p1)
|
||||
{
|
||||
return length2(p1 - p0);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T distance2
|
||||
(
|
||||
T const & p0,
|
||||
T const & p1
|
||||
)
|
||||
{
|
||||
return length2(p1 - p0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T distance2(
|
||||
const detail::tvec2<T>& p0,
|
||||
const detail::tvec2<T>& p1)
|
||||
{
|
||||
return length2(p1 - p0);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T distance2
|
||||
(
|
||||
detail::tvec2<T> const & p0,
|
||||
detail::tvec2<T> const & p1
|
||||
)
|
||||
{
|
||||
return length2(p1 - p0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T distance2(
|
||||
const detail::tvec3<T>& p0,
|
||||
const detail::tvec3<T>& p1)
|
||||
{
|
||||
return length2(p1 - p0);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T distance2
|
||||
(
|
||||
detail::tvec3<T> const & p0,
|
||||
detail::tvec3<T> const & p1
|
||||
)
|
||||
{
|
||||
return length2(p1 - p0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T distance2(
|
||||
const detail::tvec4<T>& p0,
|
||||
const detail::tvec4<T>& p1)
|
||||
{
|
||||
return length2(p1 - p0);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T distance2
|
||||
(
|
||||
detail::tvec4<T> const & p0,
|
||||
detail::tvec4<T> const & p1
|
||||
)
|
||||
{
|
||||
return length2(p1 - p0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T l1Norm(
|
||||
const detail::tvec3<T>& a,
|
||||
const detail::tvec3<T>& b)
|
||||
{
|
||||
return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T l1Norm
|
||||
(
|
||||
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);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T l1Norm(
|
||||
const detail::tvec3<T>& v)
|
||||
{
|
||||
return abs(v.x) + abs(v.y) + abs(v.z);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T l1Norm
|
||||
(
|
||||
detail::tvec3<T> const & v
|
||||
)
|
||||
{
|
||||
return abs(v.x) + abs(v.y) + abs(v.z);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T l2Norm(
|
||||
const detail::tvec3<T>& a,
|
||||
const detail::tvec3<T>& b)
|
||||
{
|
||||
return length(b - a);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T l2Norm
|
||||
(
|
||||
detail::tvec3<T> const & a,
|
||||
detail::tvec3<T> const & b
|
||||
)
|
||||
{
|
||||
return length(b - a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T l2Norm(
|
||||
const detail::tvec3<T>& v)
|
||||
{
|
||||
return length(v);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T l2Norm
|
||||
(
|
||||
detail::tvec3<T> const & v
|
||||
)
|
||||
{
|
||||
return length(v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T lxNorm(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<T>& 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));
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T lxNorm
|
||||
(
|
||||
detail::tvec3<T> const & x,
|
||||
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));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T lxNorm(
|
||||
const detail::tvec3<T>& 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));
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T lxNorm
|
||||
(
|
||||
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));
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
@ -7,17 +7,16 @@
|
||||
// File : glm/gtx/normal.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> triangleNormal
|
||||
(
|
||||
detail::tvec3<T> const & p1,
|
||||
detail::tvec3<T> const & p2,
|
||||
detail::tvec3<T> const & p3
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return normalize(cross(p1 - p2, p1 - p3));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> triangleNormal
|
||||
(
|
||||
detail::tvec3<T> const & p1,
|
||||
detail::tvec3<T> const & p2,
|
||||
detail::tvec3<T> const & p3
|
||||
)
|
||||
{
|
||||
return normalize(cross(p1 - p2, p1 - p3));
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,110 +7,109 @@
|
||||
// File : glm/gtx/normalize_dot.inl
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType normalizeDot
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
glm::inversesqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType normalizeDot
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
glm::inversesqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType normalizeDot
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
glm::inversesqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType normalizeDot
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
glm::inversesqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType normalizeDot
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
glm::inversesqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType normalizeDot
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
glm::inversesqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType normalizeDot
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
glm::inversesqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType normalizeDot
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
glm::inversesqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastNormalizeDot
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
fastInverseSqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastNormalizeDot
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
fastInverseSqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType fastNormalizeDot
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
fastInverseSqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType fastNormalizeDot
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
fastInverseSqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType fastNormalizeDot
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
fastInverseSqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType fastNormalizeDot
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
fastInverseSqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType fastNormalizeDot
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
fastInverseSqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType fastNormalizeDot
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y
|
||||
)
|
||||
{
|
||||
return
|
||||
glm::dot(x, y) *
|
||||
fastInverseSqrt(glm::dot(x, x) *
|
||||
glm::dot(y, y));
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,53 +7,52 @@
|
||||
// File : glm/gtx/optimum_pow.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType pow2(const genType& x)
|
||||
namespace glm
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType pow2(const genType& x)
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType pow3(const genType& x)
|
||||
{
|
||||
return x * x * x;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType pow3(const genType& x)
|
||||
{
|
||||
return x * x * x;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType pow4(const genType& x)
|
||||
{
|
||||
return x * x * x * x;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType pow4(const genType& x)
|
||||
{
|
||||
return x * x * x * x;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER bool powOfTwo(int x)
|
||||
{
|
||||
return !(x & (x - 1));
|
||||
}
|
||||
GLM_FUNC_QUALIFIER bool powOfTwo(int x)
|
||||
{
|
||||
return !(x & (x - 1));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
powOfTwo(x.x),
|
||||
powOfTwo(x.y));
|
||||
}
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
powOfTwo(x.x),
|
||||
powOfTwo(x.y));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
powOfTwo(x.x),
|
||||
powOfTwo(x.y),
|
||||
powOfTwo(x.z));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
powOfTwo(x.x),
|
||||
powOfTwo(x.y),
|
||||
powOfTwo(x.z),
|
||||
powOfTwo(x.w));
|
||||
}
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
powOfTwo(x.x),
|
||||
powOfTwo(x.y),
|
||||
powOfTwo(x.z));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
powOfTwo(x.x),
|
||||
powOfTwo(x.y),
|
||||
powOfTwo(x.z),
|
||||
powOfTwo(x.w));
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,38 +7,37 @@
|
||||
// File : glm/gtx/orthonormalize.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> orthonormalize
|
||||
(
|
||||
const detail::tmat3x3<T>& m
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
detail::tmat3x3<T> r = m;
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> orthonormalize
|
||||
(
|
||||
const detail::tmat3x3<T>& m
|
||||
)
|
||||
{
|
||||
detail::tmat3x3<T> r = m;
|
||||
|
||||
r[0] = normalize(r[0]);
|
||||
r[0] = normalize(r[0]);
|
||||
|
||||
float d0 = dot(r[0], r[1]);
|
||||
r[1] -= r[0] * d0;
|
||||
r[1] = normalize(r[1]);
|
||||
float d0 = dot(r[0], r[1]);
|
||||
r[1] -= r[0] * d0;
|
||||
r[1] = normalize(r[1]);
|
||||
|
||||
float d1 = dot(r[1], r[2]);
|
||||
d0 = dot(r[0], r[2]);
|
||||
r[2] -= r[0] * d0 + r[1] * d1;
|
||||
r[2] = normalize(r[2]);
|
||||
float d1 = dot(r[1], r[2]);
|
||||
d0 = dot(r[0], r[2]);
|
||||
r[2] -= r[0] * d0 + r[1] * d1;
|
||||
r[2] = normalize(r[2]);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> orthonormalize
|
||||
(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<T>& y
|
||||
)
|
||||
{
|
||||
return normalize(x - y * dot(y, x));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> orthonormalize
|
||||
(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<T>& y
|
||||
)
|
||||
{
|
||||
return normalize(x - y * dot(y, x));
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -54,24 +54,10 @@ namespace glm
|
||||
|
||||
//! Projects x a perpendicular axis of Normal.
|
||||
//! From GLM_GTX_perpendicular extension.
|
||||
template <typename T>
|
||||
detail::tvec2<T> perp(
|
||||
detail::tvec2<T> const & x,
|
||||
detail::tvec2<T> 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);
|
||||
template <typename vecType>
|
||||
vecType perp(
|
||||
vecType const & x,
|
||||
vecType const & Normal);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
@ -7,30 +7,15 @@
|
||||
// File : glm/gtx/perpendicular.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> perp(
|
||||
detail::tvec2<T> const & x,
|
||||
detail::tvec2<T> const & Normal)
|
||||
namespace glm
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
template <typename vecType>
|
||||
GLM_FUNC_QUALIFIER vecType perp
|
||||
(
|
||||
vecType const & x,
|
||||
vecType const & Normal
|
||||
)
|
||||
{
|
||||
return x - proj(x, Normal);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -53,12 +53,14 @@ namespace glm
|
||||
//! Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude.
|
||||
//! From GLM_GTX_polar_coordinates extension.
|
||||
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.
|
||||
//! From GLM_GTX_polar_coordinates extension.
|
||||
template <typename T>
|
||||
detail::tvec3<T> euclidean(const detail::tvec3<T>& polar);
|
||||
detail::tvec3<T> euclidean(
|
||||
detail::tvec3<T> const & polar);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
@ -10,8 +10,10 @@
|
||||
namespace glm
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> polar(
|
||||
const detail::tvec3<T>& euclidean)
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> polar
|
||||
(
|
||||
detail::tvec3<T> const & euclidean
|
||||
)
|
||||
{
|
||||
T length = length(euclidean);
|
||||
detail::tvec3<T> tmp = euclidean / length;
|
||||
@ -24,8 +26,10 @@ namespace glm
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> euclidean(
|
||||
const detail::tvec3<T>& polar)
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> euclidean
|
||||
(
|
||||
detail::tvec3<T> const & polar
|
||||
)
|
||||
{
|
||||
T latitude = radians(polar.x);
|
||||
T longitude = radians(polar.y);
|
||||
|
@ -52,24 +52,10 @@ namespace glm
|
||||
|
||||
//! Projects x on Normal.
|
||||
//! From GLM_GTX_projection extension.
|
||||
template <typename T>
|
||||
detail::tvec2<T> proj(
|
||||
detail::tvec2<T> const & x,
|
||||
detail::tvec2<T> 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);
|
||||
template <typename vecType>
|
||||
vecType proj(
|
||||
vecType const & x,
|
||||
vecType const & Normal);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
@ -7,30 +7,15 @@
|
||||
// File : glm/gtx/projection.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> proj(
|
||||
detail::tvec2<T> const & x,
|
||||
detail::tvec2<T> const & Normal)
|
||||
namespace glm
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
template <typename vecType>
|
||||
GLM_FUNC_QUALIFIER vecType proj
|
||||
(
|
||||
vecType const & x,
|
||||
vecType const & Normal
|
||||
)
|
||||
{
|
||||
return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -9,291 +9,290 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> cross
|
||||
(
|
||||
detail::tvec3<valType> const & v,
|
||||
detail::tquat<valType> const & q
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return inverse(q) * v;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> cross
|
||||
(
|
||||
detail::tvec3<valType> const & v,
|
||||
detail::tquat<valType> const & q
|
||||
)
|
||||
{
|
||||
return inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> cross
|
||||
(
|
||||
detail::tquat<valType> const & q,
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
return q * v;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> cross
|
||||
(
|
||||
detail::tquat<valType> const & q,
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
return q * v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> squad
|
||||
(
|
||||
detail::tquat<T> const & q1,
|
||||
detail::tquat<T> const & q2,
|
||||
detail::tquat<T> const & s1,
|
||||
detail::tquat<T> const & s2,
|
||||
T const & h)
|
||||
{
|
||||
return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * h (T(1) - h));
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> squad
|
||||
(
|
||||
detail::tquat<T> const & q1,
|
||||
detail::tquat<T> const & q2,
|
||||
detail::tquat<T> const & s1,
|
||||
detail::tquat<T> const & s2,
|
||||
T const & h)
|
||||
{
|
||||
return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * h (T(1) - h));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> intermediate
|
||||
(
|
||||
detail::tquat<T> const & prev,
|
||||
detail::tquat<T> const & curr,
|
||||
detail::tquat<T> const & next
|
||||
)
|
||||
{
|
||||
detail::tquat<T> invQuat = inverse(curr);
|
||||
return ext((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> intermediate
|
||||
(
|
||||
detail::tquat<T> const & prev,
|
||||
detail::tquat<T> const & curr,
|
||||
detail::tquat<T> const & next
|
||||
)
|
||||
{
|
||||
detail::tquat<T> invQuat = inverse(curr);
|
||||
return ext((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> exp
|
||||
(
|
||||
detail::tquat<T> const & q,
|
||||
T const & exponent
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> u(q.x, q.y, q.z);
|
||||
float a = glm::length(u);
|
||||
detail::tvec3<T> v(u / a);
|
||||
return detail::tquat<T>(cos(a), sin(a) * v);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> exp
|
||||
(
|
||||
detail::tquat<T> const & q,
|
||||
T const & exponent
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> u(q.x, q.y, q.z);
|
||||
float a = glm::length(u);
|
||||
detail::tvec3<T> v(u / a);
|
||||
return detail::tquat<T>(cos(a), sin(a) * v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> log
|
||||
(
|
||||
detail::tquat<T> const & q
|
||||
)
|
||||
{
|
||||
if((q.x == T(0)) && (q.y == T(0)) && (q.z == T(0)))
|
||||
{
|
||||
if(q.w > T(0))
|
||||
return detail::tquat<T>(log(q.w), T(0), T(0), T(0));
|
||||
else if(q.w < T(0))
|
||||
return detail::tquat<T>(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0));
|
||||
else
|
||||
return detail::tquat<T>(std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity());
|
||||
}
|
||||
else
|
||||
{
|
||||
T Vec3Len = sqrt(q.x * q.x + q.y * q.y + q.z * q.z);
|
||||
T QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w);
|
||||
T t = atan(Vec3Len, T(q.w)) / Vec3Len;
|
||||
return detail::tquat<T>(t * q.x, t * q.y, t * q.z, log(QuatLen));
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> log
|
||||
(
|
||||
detail::tquat<T> const & q
|
||||
)
|
||||
{
|
||||
if((q.x == T(0)) && (q.y == T(0)) && (q.z == T(0)))
|
||||
{
|
||||
if(q.w > T(0))
|
||||
return detail::tquat<T>(log(q.w), T(0), T(0), T(0));
|
||||
else if(q.w < T(0))
|
||||
return detail::tquat<T>(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0));
|
||||
else
|
||||
return detail::tquat<T>(std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity());
|
||||
}
|
||||
else
|
||||
{
|
||||
T Vec3Len = sqrt(q.x * q.x + q.y * q.y + q.z * q.z);
|
||||
T QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w);
|
||||
T t = atan(Vec3Len, T(q.w)) / Vec3Len;
|
||||
return detail::tquat<T>(t * q.x, t * q.y, t * q.z, log(QuatLen));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> pow
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
T const & y
|
||||
)
|
||||
{
|
||||
if(abs(x.w) > T(0.9999))
|
||||
return x;
|
||||
float Angle = acos(y);
|
||||
float NewAngle = Angle * y;
|
||||
float Div = sin(NewAngle) / sin(Angle);
|
||||
return detail::tquat<T>(
|
||||
cos(NewAngle),
|
||||
x.x * Div,
|
||||
x.y * Div,
|
||||
x.z * Div);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> pow
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
T const & y
|
||||
)
|
||||
{
|
||||
if(abs(x.w) > T(0.9999))
|
||||
return x;
|
||||
float Angle = acos(y);
|
||||
float NewAngle = Angle * y;
|
||||
float Div = sin(NewAngle) / sin(Angle);
|
||||
return detail::tquat<T>(
|
||||
cos(NewAngle),
|
||||
x.x * Div,
|
||||
x.y * Div,
|
||||
x.z * Div);
|
||||
}
|
||||
|
||||
//template <typename T>
|
||||
//GLM_FUNC_QUALIFIER detail::tquat<T> sqrt
|
||||
//(
|
||||
// detail::tquat<T> const & q
|
||||
//)
|
||||
//{
|
||||
// T q0 = T(1) - dot(q, q);
|
||||
// return T(2) * (T(1) + q0) * q;
|
||||
//}
|
||||
//template <typename T>
|
||||
//GLM_FUNC_QUALIFIER detail::tquat<T> sqrt
|
||||
//(
|
||||
// detail::tquat<T> const & q
|
||||
//)
|
||||
//{
|
||||
// T q0 = T(1) - dot(q, q);
|
||||
// return T(2) * (T(1) + q0) * q;
|
||||
//}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotate
|
||||
(
|
||||
detail::tquat<T> const & q,
|
||||
detail::tvec3<T> const & v
|
||||
)
|
||||
{
|
||||
return q * v;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotate
|
||||
(
|
||||
detail::tquat<T> const & q,
|
||||
detail::tvec3<T> const & v
|
||||
)
|
||||
{
|
||||
return q * v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotate
|
||||
(
|
||||
detail::tquat<T> const & q,
|
||||
detail::tvec4<T> const & v
|
||||
)
|
||||
{
|
||||
return q * v;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotate
|
||||
(
|
||||
detail::tquat<T> const & q,
|
||||
detail::tvec4<T> const & v
|
||||
)
|
||||
{
|
||||
return q * v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T angle
|
||||
(
|
||||
detail::tquat<T> const & x
|
||||
)
|
||||
{
|
||||
return glm::degrees(acos(x.w) * T(2));
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T angle
|
||||
(
|
||||
detail::tquat<T> const & x
|
||||
)
|
||||
{
|
||||
return glm::degrees(acos(x.w) * T(2));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> axis
|
||||
(
|
||||
detail::tquat<T> const & x
|
||||
)
|
||||
{
|
||||
T tmp1 = T(1) - x.w * x.w;
|
||||
if(tmp1 <= T(0))
|
||||
return detail::tvec3<T>(0, 0, 1);
|
||||
T tmp2 = T(1) / sqrt(tmp1);
|
||||
return detail::tvec3<T>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> axis
|
||||
(
|
||||
detail::tquat<T> const & x
|
||||
)
|
||||
{
|
||||
T tmp1 = T(1) - x.w * x.w;
|
||||
if(tmp1 <= T(0))
|
||||
return detail::tvec3<T>(0, 0, 1);
|
||||
T tmp2 = T(1) / sqrt(tmp1);
|
||||
return detail::tvec3<T>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
|
||||
(
|
||||
valType const & angle,
|
||||
valType const & x,
|
||||
valType const & y,
|
||||
valType const & z
|
||||
)
|
||||
{
|
||||
return angleAxis(angle, detail::tvec3<valType>(x, y, z));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
|
||||
(
|
||||
valType const & angle,
|
||||
valType const & x,
|
||||
valType const & y,
|
||||
valType const & z
|
||||
)
|
||||
{
|
||||
return angleAxis(angle, detail::tvec3<valType>(x, y, z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
|
||||
(
|
||||
valType const & angle,
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tquat<valType> result;
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
|
||||
(
|
||||
valType const & angle,
|
||||
detail::tvec3<valType> const & v
|
||||
)
|
||||
{
|
||||
detail::tquat<valType> result;
|
||||
|
||||
valType a = glm::radians(angle);
|
||||
valType s = glm::sin(a * valType(0.5));
|
||||
valType a = glm::radians(angle);
|
||||
valType s = glm::sin(a * valType(0.5));
|
||||
|
||||
result.w = glm::cos(a * valType(0.5));
|
||||
result.x = v.x * s;
|
||||
result.y = v.y * s;
|
||||
result.z = v.z * s;
|
||||
return result;
|
||||
}
|
||||
result.w = glm::cos(a * valType(0.5));
|
||||
result.x = v.x * s;
|
||||
result.y = v.y * s;
|
||||
result.z = v.z * s;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T extractRealComponent
|
||||
(
|
||||
detail::tquat<T> const & q
|
||||
)
|
||||
{
|
||||
T w = T(1.0) - q.x * q.x - q.y * q.y - q.z * q.z;
|
||||
if(w < T(0))
|
||||
return T(0);
|
||||
else
|
||||
return -sqrt(w);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T extractRealComponent
|
||||
(
|
||||
detail::tquat<T> const & q
|
||||
)
|
||||
{
|
||||
T w = T(1.0) - q.x * q.x - q.y * q.y - q.z * q.z;
|
||||
if(w < T(0))
|
||||
return T(0);
|
||||
else
|
||||
return -sqrt(w);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType roll
|
||||
(
|
||||
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));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType roll
|
||||
(
|
||||
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));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType pitch
|
||||
(
|
||||
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));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType pitch
|
||||
(
|
||||
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));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType yaw
|
||||
(
|
||||
detail::tquat<valType> const & q
|
||||
)
|
||||
{
|
||||
return glm::degrees(asin(valType(-2) * (q.x * q.z - q.w * q.y)));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType yaw
|
||||
(
|
||||
detail::tquat<valType> const & q
|
||||
)
|
||||
{
|
||||
return glm::degrees(asin(valType(-2) * (q.x * q.z - q.w * q.y)));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> eularAngles
|
||||
(
|
||||
detail::tquat<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(pitch(x), yaw(x), roll(x));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> eularAngles
|
||||
(
|
||||
detail::tquat<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(pitch(x), yaw(x), roll(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> shortMix
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
if(a <= typename detail::tquat<T>::value_type(0)) return x;
|
||||
if(a >= typename detail::tquat<T>::value_type(1)) return y;
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> shortMix
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
if(a <= typename detail::tquat<T>::value_type(0)) return x;
|
||||
if(a >= typename detail::tquat<T>::value_type(1)) return y;
|
||||
|
||||
T fCos = dot(x, y);
|
||||
detail::tquat<T> y2(y); //BUG!!! tquat<T> y2;
|
||||
if(fCos < T(0))
|
||||
{
|
||||
y2 = -y;
|
||||
fCos = -fCos;
|
||||
}
|
||||
T fCos = dot(x, y);
|
||||
detail::tquat<T> y2(y); //BUG!!! tquat<T> y2;
|
||||
if(fCos < T(0))
|
||||
{
|
||||
y2 = -y;
|
||||
fCos = -fCos;
|
||||
}
|
||||
|
||||
//if(fCos > 1.0f) // problem
|
||||
T k0, k1;
|
||||
if(fCos > T(0.9999))
|
||||
{
|
||||
k0 = T(1) - a;
|
||||
k1 = T(0) + a; //BUG!!! 1.0f + a;
|
||||
}
|
||||
else
|
||||
{
|
||||
T fSin = sqrt(T(1) - fCos * fCos);
|
||||
T fAngle = atan(fSin, fCos);
|
||||
T fOneOverSin = T(1) / fSin;
|
||||
k0 = sin((T(1) - a) * fAngle) * fOneOverSin;
|
||||
k1 = sin((T(0) + a) * fAngle) * fOneOverSin;
|
||||
}
|
||||
//if(fCos > 1.0f) // problem
|
||||
T k0, k1;
|
||||
if(fCos > T(0.9999))
|
||||
{
|
||||
k0 = T(1) - a;
|
||||
k1 = T(0) + a; //BUG!!! 1.0f + a;
|
||||
}
|
||||
else
|
||||
{
|
||||
T fSin = sqrt(T(1) - fCos * fCos);
|
||||
T fAngle = atan(fSin, fCos);
|
||||
T fOneOverSin = T(1) / fSin;
|
||||
k0 = sin((T(1) - a) * fAngle) * fOneOverSin;
|
||||
k1 = sin((T(0) + a) * fAngle) * fOneOverSin;
|
||||
}
|
||||
|
||||
return detail::tquat<T>(
|
||||
k0 * x.w + k1 * y2.w,
|
||||
k0 * x.x + k1 * y2.x,
|
||||
k0 * x.y + k1 * y2.y,
|
||||
k0 * x.z + k1 * y2.z);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> fastMix
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
return glm::normalize(x * (T(1) - a) + (y * a));
|
||||
}
|
||||
return detail::tquat<T>(
|
||||
k0 * x.w + k1 * y2.w,
|
||||
k0 * x.x + k1 * y2.x,
|
||||
k0 * x.y + k1 * y2.y,
|
||||
k0 * x.z + k1 * y2.z);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> fastMix
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
return glm::normalize(x * (T(1) - a) + (y * a));
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -2,588 +2,181 @@
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-10-09
|
||||
// Updated : 2008-10-09
|
||||
// Updated : 2011-10-14
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/reciprocal.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
#include "../core/_vectorize.hpp"
|
||||
|
||||
// sec
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sec
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sec' only accept floating-point values");
|
||||
// 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");
|
||||
|
||||
return genType(1) / glm::cos(angle);
|
||||
}
|
||||
return genType(1) / glm::cos(angle);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> sec
|
||||
(
|
||||
detail::tvec2<valType> const & angle
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
sec(angle.x),
|
||||
sec(angle.y));
|
||||
}
|
||||
VECTORIZE_VEC(sec)
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> sec
|
||||
(
|
||||
detail::tvec3<valType> const & angle
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
sec(angle.x),
|
||||
sec(angle.y),
|
||||
sec(angle.z));
|
||||
}
|
||||
// csc
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType csc
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csc' only accept floating-point values");
|
||||
|
||||
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));
|
||||
}
|
||||
return genType(1) / glm::sin(angle);
|
||||
}
|
||||
|
||||
// csc
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType csc
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csc' only accept floating-point values");
|
||||
VECTORIZE_VEC(csc)
|
||||
|
||||
return genType(1) / glm::sin(angle);
|
||||
}
|
||||
// cot
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType cot
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cot' only accept floating-point values");
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> csc
|
||||
(
|
||||
detail::tvec2<valType> const & angle
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
csc(angle.x),
|
||||
csc(angle.y));
|
||||
}
|
||||
return genType(1) / glm::tan(angle);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> csc
|
||||
(
|
||||
detail::tvec3<valType> const & angle
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
csc(angle.x),
|
||||
csc(angle.y),
|
||||
csc(angle.z));
|
||||
}
|
||||
VECTORIZE_VEC(cot)
|
||||
|
||||
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
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cot' only accept floating-point values");
|
||||
|
||||
return genType(1) / glm::tan(angle);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
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>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> cot
|
||||
(
|
||||
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
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asec' only accept floating-point values");
|
||||
// asec
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType asec
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
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>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> asec
|
||||
(
|
||||
detail::tvec2<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
asec(x.x),
|
||||
asec(x.y));
|
||||
}
|
||||
VECTORIZE_VEC(asec)
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> asec
|
||||
(
|
||||
detail::tvec3<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
asec(x.x),
|
||||
asec(x.y),
|
||||
asec(x.z));
|
||||
}
|
||||
// acsc
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acsc
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsc' only accept floating-point values");
|
||||
|
||||
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));
|
||||
}
|
||||
return asin(genType(1) / x);
|
||||
}
|
||||
|
||||
// acsc
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acsc
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsc' only accept floating-point values");
|
||||
VECTORIZE_VEC(acsc)
|
||||
|
||||
return asin(genType(1) / x);
|
||||
}
|
||||
// acot
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acot
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acot' only accept floating-point values");
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> acsc
|
||||
(
|
||||
detail::tvec2<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
acsc(x.x),
|
||||
acsc(x.y));
|
||||
}
|
||||
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
|
||||
return pi_over_2 - atan(x);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> acsc
|
||||
(
|
||||
detail::tvec3<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
acsc(x.x),
|
||||
acsc(x.y),
|
||||
acsc(x.z));
|
||||
}
|
||||
VECTORIZE_VEC(acot)
|
||||
|
||||
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));
|
||||
}
|
||||
// sech
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sech
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sech' only accept floating-point values");
|
||||
|
||||
// acot
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acot
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acot' only accept floating-point values");
|
||||
return genType(1) / glm::cosh(angle);
|
||||
}
|
||||
|
||||
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
|
||||
return pi_over_2 - atan(x);
|
||||
}
|
||||
VECTORIZE_VEC(sech)
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> acot
|
||||
(
|
||||
detail::tvec2<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
acot(x.x),
|
||||
acot(x.y));
|
||||
}
|
||||
// csch
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType csch
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csch' only accept floating-point values");
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> acot
|
||||
(
|
||||
detail::tvec3<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
acot(x.x),
|
||||
acot(x.y),
|
||||
acot(x.z));
|
||||
}
|
||||
return genType(1) / glm::sinh(angle);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(csch)
|
||||
|
||||
// sech
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sech
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sech' only accept floating-point values");
|
||||
// coth
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType coth
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'coth' only accept floating-point values");
|
||||
|
||||
return genType(1) / glm::cosh(angle);
|
||||
}
|
||||
return glm::cosh(angle) / glm::sinh(angle);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> sech
|
||||
(
|
||||
detail::tvec2<valType> const & angle
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
sech(angle.x),
|
||||
sech(angle.y));
|
||||
}
|
||||
VECTORIZE_VEC(coth)
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> sech
|
||||
(
|
||||
detail::tvec3<valType> const & angle
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
sech(angle.x),
|
||||
sech(angle.y),
|
||||
sech(angle.z));
|
||||
}
|
||||
// asech
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType asech
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asech' only accept floating-point values");
|
||||
|
||||
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));
|
||||
}
|
||||
return acosh(genType(1) / x);
|
||||
}
|
||||
|
||||
// csch
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType csch
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csch' only accept floating-point values");
|
||||
VECTORIZE_VEC(asech)
|
||||
|
||||
return genType(1) / glm::sinh(angle);
|
||||
}
|
||||
// acsch
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acsch
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsch' only accept floating-point values");
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> csch
|
||||
(
|
||||
detail::tvec2<valType> const & angle
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
csch(angle.x),
|
||||
csch(angle.y));
|
||||
}
|
||||
return asinh(genType(1) / x);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> csch
|
||||
(
|
||||
detail::tvec3<valType> const & angle
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
csch(angle.x),
|
||||
csch(angle.y),
|
||||
csch(angle.z));
|
||||
}
|
||||
VECTORIZE_VEC(acsch)
|
||||
|
||||
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));
|
||||
}
|
||||
// acoth
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType acoth
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acoth' only accept floating-point values");
|
||||
|
||||
// coth
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType coth
|
||||
(
|
||||
genType const & angle
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'coth' only accept floating-point values");
|
||||
|
||||
return glm::cosh(angle) / glm::sinh(angle);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
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>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> coth
|
||||
(
|
||||
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
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asech' only accept floating-point values");
|
||||
|
||||
return acosh(genType(1) / x);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
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>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> asech
|
||||
(
|
||||
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
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsch' only accept floating-point values");
|
||||
|
||||
return asinh(genType(1) / x);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
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>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> acsch
|
||||
(
|
||||
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
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acoth' only accept floating-point values");
|
||||
|
||||
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));
|
||||
}
|
||||
return atanh(genType(1) / x);
|
||||
}
|
||||
|
||||
VECTORIZE_VEC(acoth)
|
||||
}//namespace glm
|
||||
|
@ -7,139 +7,158 @@
|
||||
// File : glm/gtx/rotate_vector.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> rotate(
|
||||
detail::tvec2<T> const & v,
|
||||
T const & angle)
|
||||
namespace glm
|
||||
{
|
||||
detail::tvec2<T> Result;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos - v.y * Sin;
|
||||
Result.y = v.x * Sin + v.y * Cos;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> rotate
|
||||
(
|
||||
detail::tvec2<T> const & v,
|
||||
T const & angle
|
||||
)
|
||||
{
|
||||
detail::tvec2<T> Result;
|
||||
T const Cos = cos(radians(angle));
|
||||
T const Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos - v.y * Sin;
|
||||
Result.y = v.x * Sin + v.y * Cos;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotate(
|
||||
const detail::tvec3<T> & v,
|
||||
T const & angle,
|
||||
const detail::tvec3<T> & normal)
|
||||
{
|
||||
return detail::tmat3x3<T>(glm::rotate(angle, normal)) * v;
|
||||
}
|
||||
/*
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateGTX(
|
||||
const detail::tvec3<T>& x,
|
||||
T angle,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
return x * Cos + ((x * normal) * (T(1) - Cos)) * normal + cross(x, normal) * Sin;
|
||||
}
|
||||
*/
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotate(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & angle,
|
||||
detail::tvec3<T> const & normal)
|
||||
{
|
||||
return rotate(angle, normal) * v;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotate
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & angle,
|
||||
detail::tvec3<T> const & normal
|
||||
)
|
||||
{
|
||||
return detail::tmat3x3<T>(glm::rotate(angle, normal)) * v;
|
||||
}
|
||||
/*
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateGTX(
|
||||
const detail::tvec3<T>& x,
|
||||
T angle,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
return x * Cos + ((x * normal) * (T(1) - Cos)) * normal + cross(x, normal) * Sin;
|
||||
}
|
||||
*/
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotate
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & angle,
|
||||
detail::tvec3<T> const & normal
|
||||
)
|
||||
{
|
||||
return rotate(angle, normal) * v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateX(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & angle)
|
||||
{
|
||||
detail::tvec3<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.y = v.y * Cos - v.z * Sin;
|
||||
Result.z = v.y * Sin + v.z * Cos;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateX
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & angle
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.y = v.y * Cos - v.z * Sin;
|
||||
Result.z = v.y * Sin + v.z * Cos;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateY(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & angle)
|
||||
{
|
||||
detail::tvec3<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos + v.z * Sin;
|
||||
Result.z = -v.x * Sin + v.z * Cos;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateY
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & angle
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos + v.z * Sin;
|
||||
Result.z = -v.x * Sin + v.z * Cos;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateZ(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & angle)
|
||||
{
|
||||
detail::tvec3<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos - v.y * Sin;
|
||||
Result.y = v.x * Sin + v.y * Cos;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rotateZ
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & angle
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos - v.y * Sin;
|
||||
Result.y = v.x * Sin + v.y * Cos;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateX(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & angle)
|
||||
{
|
||||
detail::tvec4<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.y = v.y * Cos - v.z * Sin;
|
||||
Result.z = v.y * Sin + v.z * Cos;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateX
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & angle
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.y = v.y * Cos - v.z * Sin;
|
||||
Result.z = v.y * Sin + v.z * Cos;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateY(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & angle)
|
||||
{
|
||||
detail::tvec4<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos + v.z * Sin;
|
||||
Result.z = -v.x * Sin + v.z * Cos;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateY
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & angle
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos + v.z * Sin;
|
||||
Result.z = -v.x * Sin + v.z * Cos;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateZ(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & angle)
|
||||
{
|
||||
detail::tvec4<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos - v.y * Sin;
|
||||
Result.y = v.x * Sin + v.y * Cos;
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> rotateZ
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & angle
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result = v;
|
||||
const T Cos = cos(radians(angle));
|
||||
const T Sin = sin(radians(angle));
|
||||
Result.x = v.x * Cos - v.y * Sin;
|
||||
Result.y = v.x * Sin + v.y * Cos;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> orientation(
|
||||
detail::tvec3<T> const & Normal,
|
||||
detail::tvec3<T> const & Up)
|
||||
{
|
||||
if(all(equal(Normal, Up)))
|
||||
return detail::tmat4x4<T>(T(1));
|
||||
|
||||
detail::tvec3<T> RotationAxis = cross(Up, Normal);
|
||||
T Angle = degrees(acos(dot(Normal, Up)));
|
||||
return rotate(Angle, RotationAxis);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> orientation
|
||||
(
|
||||
detail::tvec3<T> const & Normal,
|
||||
detail::tvec3<T> const & Up
|
||||
)
|
||||
{
|
||||
if(all(equal(Normal, Up)))
|
||||
return detail::tmat4x4<T>(T(1));
|
||||
|
||||
detail::tvec3<T> RotationAxis = cross(Up, Normal);
|
||||
T Angle = degrees(acos(dot(Normal, Up)));
|
||||
return rotate(Angle, RotationAxis);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,149 +7,148 @@
|
||||
// File : glm/gtx/transform2.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearX2D(
|
||||
const detail::tmat3x3<T>& m,
|
||||
T s)
|
||||
namespace glm
|
||||
{
|
||||
detail::tmat3x3<T> r(1);
|
||||
r[0][1] = s;
|
||||
return m * r;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearX2D(
|
||||
const detail::tmat3x3<T>& m,
|
||||
T s)
|
||||
{
|
||||
detail::tmat3x3<T> r(1);
|
||||
r[0][1] = s;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearY2D(
|
||||
const detail::tmat3x3<T>& m,
|
||||
T s)
|
||||
{
|
||||
detail::tmat3x3<T> r(1);
|
||||
r[1][0] = s;
|
||||
return m * r;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearY2D(
|
||||
const detail::tmat3x3<T>& m,
|
||||
T s)
|
||||
{
|
||||
detail::tmat3x3<T> r(1);
|
||||
r[1][0] = s;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearX3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
T s,
|
||||
T t)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[1][0] = s;
|
||||
r[2][0] = t;
|
||||
return m * r;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearX3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
T s,
|
||||
T t)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[1][0] = s;
|
||||
r[2][0] = t;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearY3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
T s,
|
||||
T t)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[0][1] = s;
|
||||
r[2][1] = t;
|
||||
return m * r;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearY3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
T s,
|
||||
T t)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[0][1] = s;
|
||||
r[2][1] = t;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearZ3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
T s,
|
||||
T t)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[0][2] = s;
|
||||
r[1][2] = t;
|
||||
return m * r;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearZ3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
T s,
|
||||
T t)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[0][2] = s;
|
||||
r[1][2] = t;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> reflect2D(
|
||||
const detail::tmat3x3<T>& m,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
detail::tmat3x3<T> r(1);
|
||||
r[0][0] = 1 - 2 * normal.x * normal.x;
|
||||
r[0][1] = -2 * normal.x * normal.y;
|
||||
r[1][0] = -2 * normal.x * normal.y;
|
||||
r[1][1] = 1 - 2 * normal.y * normal.y;
|
||||
return m * r;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> reflect2D(
|
||||
const detail::tmat3x3<T>& m,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
detail::tmat3x3<T> r(1);
|
||||
r[0][0] = 1 - 2 * normal.x * normal.x;
|
||||
r[0][1] = -2 * normal.x * normal.y;
|
||||
r[1][0] = -2 * normal.x * normal.y;
|
||||
r[1][1] = 1 - 2 * normal.y * normal.y;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> reflect3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[0][0] = 1 - 2 * normal.x * normal.x;
|
||||
r[0][1] = -2 * normal.x * normal.y;
|
||||
r[0][2] = -2 * normal.x * normal.z;
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> reflect3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[0][0] = 1 - 2 * normal.x * normal.x;
|
||||
r[0][1] = -2 * normal.x * normal.y;
|
||||
r[0][2] = -2 * normal.x * normal.z;
|
||||
|
||||
r[1][0] = -2 * normal.x * normal.y;
|
||||
r[1][1] = 1 - 2 * normal.y * normal.y;
|
||||
r[1][2] = -2 * normal.y * normal.z;
|
||||
r[1][0] = -2 * normal.x * normal.y;
|
||||
r[1][1] = 1 - 2 * normal.y * normal.y;
|
||||
r[1][2] = -2 * normal.y * normal.z;
|
||||
|
||||
r[2][0] = -2 * normal.x * normal.z;
|
||||
r[2][1] = -2 * normal.y * normal.z;
|
||||
r[2][2] = 1 - 2 * normal.z * normal.z;
|
||||
return m * r;
|
||||
}
|
||||
r[2][0] = -2 * normal.x * normal.z;
|
||||
r[2][1] = -2 * normal.y * normal.z;
|
||||
r[2][2] = 1 - 2 * normal.z * normal.z;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> proj2D(
|
||||
const detail::tmat3x3<T>& m,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
detail::tmat3x3<T> r(1);
|
||||
r[0][0] = 1 - normal.x * normal.x;
|
||||
r[0][1] = - normal.x * normal.y;
|
||||
r[1][0] = - normal.x * normal.y;
|
||||
r[1][1] = 1 - normal.y * normal.y;
|
||||
return m * r;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> proj2D(
|
||||
const detail::tmat3x3<T>& m,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
detail::tmat3x3<T> r(1);
|
||||
r[0][0] = 1 - normal.x * normal.x;
|
||||
r[0][1] = - normal.x * normal.y;
|
||||
r[1][0] = - normal.x * normal.y;
|
||||
r[1][1] = 1 - normal.y * normal.y;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> proj3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[0][0] = 1 - normal.x * normal.x;
|
||||
r[0][1] = - normal.x * normal.y;
|
||||
r[0][2] = - normal.x * normal.z;
|
||||
r[1][0] = - normal.x * normal.y;
|
||||
r[1][1] = 1 - normal.y * normal.y;
|
||||
r[1][2] = - normal.y * normal.z;
|
||||
r[2][0] = - normal.x * normal.z;
|
||||
r[2][1] = - normal.y * normal.z;
|
||||
r[2][2] = 1 - normal.z * normal.z;
|
||||
return m * r;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> proj3D(
|
||||
const detail::tmat4x4<T>& m,
|
||||
const detail::tvec3<T>& normal)
|
||||
{
|
||||
detail::tmat4x4<T> r(1);
|
||||
r[0][0] = 1 - normal.x * normal.x;
|
||||
r[0][1] = - normal.x * normal.y;
|
||||
r[0][2] = - normal.x * normal.z;
|
||||
r[1][0] = - normal.x * normal.y;
|
||||
r[1][1] = 1 - normal.y * normal.y;
|
||||
r[1][2] = - normal.y * normal.z;
|
||||
r[2][0] = - normal.x * normal.z;
|
||||
r[2][1] = - normal.y * normal.z;
|
||||
r[2][2] = 1 - normal.z * normal.z;
|
||||
return m * r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias(
|
||||
T scale,
|
||||
T bias)
|
||||
{
|
||||
detail::tmat4x4<T> result;
|
||||
result[3] = detail::tvec4<T>(detail::tvec3<T>(bias), T(1));
|
||||
result[0][0] = scale;
|
||||
result[1][1] = scale;
|
||||
result[2][2] = scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias(
|
||||
const detail::tmat4x4<T>& m,
|
||||
T scale,
|
||||
T bias)
|
||||
{
|
||||
return m * scaleBias(scale, bias);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias(
|
||||
T scale,
|
||||
T bias)
|
||||
{
|
||||
detail::tmat4x4<T> result;
|
||||
result[3] = detail::tvec4<T>(detail::tvec3<T>(bias), T(1));
|
||||
result[0][0] = scale;
|
||||
result[1][1] = scale;
|
||||
result[2][2] = scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias(
|
||||
const detail::tmat4x4<T>& m,
|
||||
T scale,
|
||||
T bias)
|
||||
{
|
||||
return m * scaleBias(scale, bias);
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
|
343
glm/gtx/ulp.inl
343
glm/gtx/ulp.inl
@ -42,34 +42,34 @@ typedef union
|
||||
} ieee_double_shape_type;
|
||||
|
||||
#define GLM_EXTRACT_WORDS(ix0,ix1,d) \
|
||||
do { \
|
||||
ieee_double_shape_type ew_u; \
|
||||
ew_u.value = (d); \
|
||||
(ix0) = ew_u.parts.msw; \
|
||||
(ix1) = ew_u.parts.lsw; \
|
||||
} while (0)
|
||||
do { \
|
||||
ieee_double_shape_type ew_u; \
|
||||
ew_u.value = (d); \
|
||||
(ix0) = ew_u.parts.msw; \
|
||||
(ix1) = ew_u.parts.lsw; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_GET_FLOAT_WORD(i,d) \
|
||||
do { \
|
||||
ieee_float_shape_type gf_u; \
|
||||
gf_u.value = (d); \
|
||||
(i) = gf_u.word; \
|
||||
} while (0)
|
||||
do { \
|
||||
ieee_float_shape_type gf_u; \
|
||||
gf_u.value = (d); \
|
||||
(i) = gf_u.word; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_SET_FLOAT_WORD(d,i) \
|
||||
do { \
|
||||
ieee_float_shape_type sf_u; \
|
||||
sf_u.word = (i); \
|
||||
(d) = sf_u.value; \
|
||||
} while (0)
|
||||
do { \
|
||||
ieee_float_shape_type sf_u; \
|
||||
sf_u.word = (i); \
|
||||
(d) = sf_u.value; \
|
||||
} while (0)
|
||||
|
||||
#define GLM_INSERT_WORDS(d,ix0,ix1) \
|
||||
do { \
|
||||
ieee_double_shape_type iw_u; \
|
||||
iw_u.parts.msw = (ix0); \
|
||||
iw_u.parts.lsw = (ix1); \
|
||||
(d) = iw_u.value; \
|
||||
} while (0)
|
||||
do { \
|
||||
ieee_double_shape_type iw_u; \
|
||||
iw_u.parts.msw = (ix0); \
|
||||
iw_u.parts.lsw = (ix1); \
|
||||
(d) = iw_u.value; \
|
||||
} while (0)
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
@ -181,218 +181,119 @@ namespace detail
|
||||
# define GLM_NEXT_AFTER_DBL(x, toward) nextafter((x), (toward))
|
||||
#endif
|
||||
|
||||
namespace glm{
|
||||
|
||||
GLM_FUNC_QUALIFIER float next_float(float const & x)
|
||||
namespace glm
|
||||
{
|
||||
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::max());
|
||||
}
|
||||
GLM_FUNC_QUALIFIER float next_float(float const & x)
|
||||
{
|
||||
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::max());
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double next_float(double const & x)
|
||||
{
|
||||
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::max());
|
||||
}
|
||||
GLM_FUNC_QUALIFIER double next_float(double const & x)
|
||||
{
|
||||
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::max());
|
||||
}
|
||||
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x)
|
||||
{
|
||||
vecType<T> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = next_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x)
|
||||
{
|
||||
vecType<T> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = next_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float prev_float(float const & x)
|
||||
{
|
||||
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::min());
|
||||
}
|
||||
GLM_FUNC_QUALIFIER float prev_float(float const & x)
|
||||
{
|
||||
return GLM_NEXT_AFTER_FLT(x, std::numeric_limits<float>::min());
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double prev_float(double const & x)
|
||||
{
|
||||
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::min());
|
||||
}
|
||||
GLM_FUNC_QUALIFIER double prev_float(double const & x)
|
||||
{
|
||||
return GLM_NEXT_AFTER_DBL(x, std::numeric_limits<double>::min());
|
||||
}
|
||||
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x)
|
||||
{
|
||||
vecType<T> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = prev_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x)
|
||||
{
|
||||
vecType<T> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = prev_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps)
|
||||
{
|
||||
T temp = x;
|
||||
for(std::size_t i = 0; i < ulps; ++i)
|
||||
temp = next_float(temp);
|
||||
return temp;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps)
|
||||
{
|
||||
T temp = x;
|
||||
for(std::size_t i = 0; i < ulps; ++i)
|
||||
temp = next_float(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x, vecType<uint> const & ulps)
|
||||
{
|
||||
vecType<T> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = next_float(x[i], ulps[i]);
|
||||
return Result;
|
||||
}
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T> next_float(vecType<T> const & x, vecType<uint> const & ulps)
|
||||
{
|
||||
vecType<T> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = next_float(x[i], ulps[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps)
|
||||
{
|
||||
T temp = x;
|
||||
for(std::size_t i = 0; i < ulps; ++i)
|
||||
temp = prev_float(temp);
|
||||
return temp;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps)
|
||||
{
|
||||
T temp = x;
|
||||
for(std::size_t i = 0; i < ulps; ++i)
|
||||
temp = prev_float(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x, vecType<uint> const & ulps)
|
||||
{
|
||||
vecType<T> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = prev_float(x[i], ulps[i]);
|
||||
return Result;
|
||||
}
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<T> prev_float(vecType<T> const & x, vecType<uint> const & ulps)
|
||||
{
|
||||
vecType<T> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = prev_float(x[i], ulps[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y)
|
||||
{
|
||||
uint ulp = 0;
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y)
|
||||
{
|
||||
uint ulp = 0;
|
||||
|
||||
if(x < y)
|
||||
{
|
||||
T temp = x;
|
||||
while(temp != y && ulp < std::numeric_limits<std::size_t>::max())
|
||||
{
|
||||
++ulp;
|
||||
temp = next_float(temp);
|
||||
}
|
||||
}
|
||||
else if(y < x)
|
||||
{
|
||||
T temp = y;
|
||||
while(temp != x && ulp < std::numeric_limits<std::size_t>::max())
|
||||
{
|
||||
++ulp;
|
||||
temp = next_float(temp);
|
||||
}
|
||||
}
|
||||
else // ==
|
||||
{
|
||||
if(x < y)
|
||||
{
|
||||
T temp = x;
|
||||
while(temp != y && ulp < std::numeric_limits<std::size_t>::max())
|
||||
{
|
||||
++ulp;
|
||||
temp = next_float(temp);
|
||||
}
|
||||
}
|
||||
else if(y < x)
|
||||
{
|
||||
T temp = y;
|
||||
while(temp != x && ulp < std::numeric_limits<std::size_t>::max())
|
||||
{
|
||||
++ulp;
|
||||
temp = next_float(temp);
|
||||
}
|
||||
}
|
||||
else // ==
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ulp;
|
||||
}
|
||||
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y)
|
||||
{
|
||||
vecType<uint> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = float_distance(x[i], y[i]);
|
||||
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]));
|
||||
}
|
||||
*/
|
||||
return ulp;
|
||||
}
|
||||
|
||||
template<typename T, template<typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<uint> float_distance(vecType<T> const & x, vecType<T> const & y)
|
||||
{
|
||||
vecType<uint> Result;
|
||||
for(std::size_t i = 0; i < Result.length(); ++i)
|
||||
Result[i] = float_distance(x[i], y[i]);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,7 +7,7 @@
|
||||
// File : glm/gtx/unsigned_int.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
namespace glm
|
||||
{
|
||||
|
||||
}//namespace glm
|
||||
|
@ -7,48 +7,47 @@
|
||||
// File : glm/gtx/vector_access.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER void set
|
||||
(
|
||||
detail::tvec2<valType>& v,
|
||||
valType const & x,
|
||||
valType const & y
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER void set
|
||||
(
|
||||
detail::tvec2<valType>& v,
|
||||
valType const & x,
|
||||
valType const & y
|
||||
)
|
||||
{
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER void set
|
||||
(
|
||||
detail::tvec3<valType>& v,
|
||||
valType const & x,
|
||||
valType const & y,
|
||||
valType const & z
|
||||
)
|
||||
{
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
v.z = z;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER void set
|
||||
(
|
||||
detail::tvec4<valType>& v,
|
||||
valType const & x,
|
||||
valType const & y,
|
||||
valType const & z,
|
||||
valType const & w
|
||||
)
|
||||
{
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
v.z = z;
|
||||
v.w = w;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER void set
|
||||
(
|
||||
detail::tvec3<valType>& v,
|
||||
valType const & x,
|
||||
valType const & y,
|
||||
valType const & z
|
||||
)
|
||||
{
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
v.z = z;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER void set
|
||||
(
|
||||
detail::tvec4<valType>& v,
|
||||
valType const & x,
|
||||
valType const & y,
|
||||
valType const & z,
|
||||
valType const & w
|
||||
)
|
||||
{
|
||||
v.x = x;
|
||||
v.y = y;
|
||||
v.z = z;
|
||||
v.w = w;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,48 +7,47 @@
|
||||
// File : glm/gtx/vector_angle.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type angle
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return degrees(acos(dot(x, y)));
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type angle
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y
|
||||
)
|
||||
{
|
||||
return degrees(acos(dot(x, y)));
|
||||
}
|
||||
|
||||
//! \todo epsilon is hard coded to 0.01
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType orientedAngle
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y
|
||||
)
|
||||
{
|
||||
valType Angle = glm::degrees(acos(dot(x, y)));
|
||||
detail::tvec2<valType> TransformedVector = glm::rotate(x, Angle);
|
||||
if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
|
||||
return Angle;
|
||||
else
|
||||
return -Angle;
|
||||
}
|
||||
//! \todo epsilon is hard coded to 0.01
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType orientedAngle
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y
|
||||
)
|
||||
{
|
||||
valType Angle = glm::degrees(acos(dot(x, y)));
|
||||
detail::tvec2<valType> TransformedVector = glm::rotate(x, Angle);
|
||||
if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
|
||||
return Angle;
|
||||
else
|
||||
return -Angle;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType orientedAngle
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
detail::tvec3<valType> const & ref
|
||||
)
|
||||
{
|
||||
valType Angle = glm::degrees(glm::acos(glm::dot(x, y)));
|
||||
|
||||
if(glm::dot(ref, glm::cross(x, y)) < valType(0))
|
||||
return -Angle;
|
||||
else
|
||||
return Angle;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType orientedAngle
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
detail::tvec3<valType> const & ref
|
||||
)
|
||||
{
|
||||
valType Angle = glm::degrees(glm::acos(glm::dot(x, y)));
|
||||
|
||||
if(glm::dot(ref, glm::cross(x, y)) < valType(0))
|
||||
return -Angle;
|
||||
else
|
||||
return Angle;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -12,159 +12,158 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool areCollinear
|
||||
(
|
||||
detail::tvec2<T> const & v0,
|
||||
detail::tvec2<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return length(cross(detail::tvec3<T>(v0, T(0)), detail::tvec3<T>(v1, T(0)))) < epsilon;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool areCollinear
|
||||
(
|
||||
detail::tvec2<T> const & v0,
|
||||
detail::tvec2<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return length(cross(detail::tvec3<T>(v0, T(0)), detail::tvec3<T>(v1, T(0)))) < epsilon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool areCollinear
|
||||
(
|
||||
detail::tvec3<T> const & v0,
|
||||
detail::tvec3<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return length(cross(v0, v1)) < epsilon;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool areCollinear
|
||||
(
|
||||
detail::tvec3<T> const & v0,
|
||||
detail::tvec3<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return length(cross(v0, v1)) < epsilon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool areCollinear
|
||||
(
|
||||
detail::tvec4<T> const & v0,
|
||||
detail::tvec4<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return length(cross(detail::tvec3<T>(v0), detail::tvec3<T>(v1))) < epsilon;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool areCollinear
|
||||
(
|
||||
detail::tvec4<T> const & v0,
|
||||
detail::tvec4<T> const & v1,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return length(cross(detail::tvec3<T>(v0), detail::tvec3<T>(v1))) < epsilon;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool areOpposite
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
assert(isNormalized(v0) && isNormalized(v1));
|
||||
return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon);
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool areOpposite
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
assert(isNormalized(v0) && isNormalized(v1));
|
||||
return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool areOrthogonal
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(dot(v0, v1)) <= max(
|
||||
typename genType::value_type(1),
|
||||
length(v0)) * max(
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool areOrthogonal
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(dot(v0, v1)) <= max(
|
||||
typename genType::value_type(1),
|
||||
length(v1)) * epsilon;
|
||||
}
|
||||
length(v0)) * max(
|
||||
typename genType::value_type(1),
|
||||
length(v1)) * epsilon;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isNormalized
|
||||
(
|
||||
genType const & v,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(length(v) - typename genType::value_type(1)) <= typename genType::value_type(2) * epsilon;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isNormalized
|
||||
(
|
||||
genType const & v,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(length(v) - typename genType::value_type(1)) <= typename genType::value_type(2) * epsilon;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isNull
|
||||
(
|
||||
genType const & v,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return length(v) <= epsilon;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isNull
|
||||
(
|
||||
genType const & v,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return length(v) <= epsilon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool isCompNull
|
||||
(
|
||||
T const & s,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(s) < epsilon;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool isCompNull
|
||||
(
|
||||
T const & s,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(s) < epsilon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isCompNull
|
||||
(
|
||||
detail::tvec2<T> const & v,
|
||||
T const & epsilon)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
(abs(v.x) < epsilon),
|
||||
(abs(v.y) < epsilon));
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isCompNull
|
||||
(
|
||||
detail::tvec2<T> const & v,
|
||||
T const & epsilon)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
(abs(v.x) < epsilon),
|
||||
(abs(v.y) < epsilon));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isCompNull
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(v.x) < epsilon,
|
||||
abs(v.y) < epsilon,
|
||||
abs(v.z) < epsilon);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isCompNull
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(v.x) < epsilon,
|
||||
abs(v.y) < epsilon,
|
||||
abs(v.z) < epsilon);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isCompNull
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(v.x) < epsilon,
|
||||
abs(v.y) < epsilon,
|
||||
abs(v.z) < epsilon,
|
||||
abs(v.w) < epsilon);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isCompNull
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(v.x) < epsilon,
|
||||
abs(v.y) < epsilon,
|
||||
abs(v.z) < epsilon,
|
||||
abs(v.w) < epsilon);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool areOrthonormal
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool areSimilar
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
bool similar = true;
|
||||
for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++)
|
||||
similar = (abs(v0[i] - v1[i]) <= epsilon);
|
||||
return similar;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool areOrthonormal
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon);
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool areSimilar
|
||||
(
|
||||
genType const & v0,
|
||||
genType const & v1,
|
||||
typename genType::value_type const & epsilon
|
||||
)
|
||||
{
|
||||
bool similar = true;
|
||||
for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++)
|
||||
similar = (abs(v0[i] - v1[i]) <= epsilon);
|
||||
return similar;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,119 +7,118 @@
|
||||
// File : glm/gtx/verbose_operator.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType add(genType const & a, genType const & b)
|
||||
namespace glm
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType add(genType const & a, genType const & b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sub(genType const & a, genType const & b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType sub(genType const & a, genType const & b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> mul
|
||||
(
|
||||
detail::tmat2x2<T> const & a,
|
||||
detail::tmat2x2<T> const & b
|
||||
)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<T> mul
|
||||
(
|
||||
detail::tmat2x2<T> const & a,
|
||||
detail::tmat2x2<T> const & b
|
||||
)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> mul
|
||||
(
|
||||
detail::tmat3x3<T> const & a,
|
||||
detail::tmat3x3<T> const & b
|
||||
)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> mul
|
||||
(
|
||||
detail::tmat3x3<T> const & a,
|
||||
detail::tmat3x3<T> const & b
|
||||
)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> mul
|
||||
(
|
||||
detail::tmat4x4<T> const & a,
|
||||
detail::tmat4x4<T> const & b
|
||||
)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> mul
|
||||
(
|
||||
detail::tmat4x4<T> const & a,
|
||||
detail::tmat4x4<T> const & b
|
||||
)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> mul
|
||||
(
|
||||
detail::tmat2x2<T> const & m,
|
||||
detail::tvec2<T> const & v
|
||||
)
|
||||
{
|
||||
return m * v;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> mul
|
||||
(
|
||||
detail::tmat2x2<T> const & m,
|
||||
detail::tvec2<T> const & v
|
||||
)
|
||||
{
|
||||
return m * v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> mul
|
||||
(
|
||||
detail::tmat3x3<T> const & m,
|
||||
detail::tvec3<T> const & v)
|
||||
{
|
||||
return m * v;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> mul
|
||||
(
|
||||
detail::tmat3x3<T> const & m,
|
||||
detail::tvec3<T> const & v)
|
||||
{
|
||||
return m * v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> mul
|
||||
(
|
||||
detail::tmat4x4<T> const & m,
|
||||
detail::tvec4<T> const & v
|
||||
)
|
||||
{
|
||||
return m * v;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> mul
|
||||
(
|
||||
detail::tmat4x4<T> const & m,
|
||||
detail::tvec4<T> const & v
|
||||
)
|
||||
{
|
||||
return m * v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> mul
|
||||
(
|
||||
detail::tvec2<T> const & v,
|
||||
detail::tmat2x2<T> const & m
|
||||
)
|
||||
{
|
||||
return v * m;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> mul
|
||||
(
|
||||
detail::tvec2<T> const & v,
|
||||
detail::tmat2x2<T> const & m
|
||||
)
|
||||
{
|
||||
return v * m;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> mul
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
detail::tmat3x3<T> const & m
|
||||
)
|
||||
{
|
||||
return v * m;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> mul
|
||||
(
|
||||
detail::tvec3<T> const & v,
|
||||
detail::tmat3x3<T> const & m
|
||||
)
|
||||
{
|
||||
return v * m;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> mul
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
detail::tmat4x4<T> const & m
|
||||
)
|
||||
{
|
||||
return v * m;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> mul
|
||||
(
|
||||
detail::tvec4<T> const & v,
|
||||
detail::tmat4x4<T> const & m
|
||||
)
|
||||
{
|
||||
return v * m;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType div(genType const & a, genType const & b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
template <typename genTypeT, typename genTypeU, typename genTypeV>
|
||||
GLM_FUNC_QUALIFIER genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c)
|
||||
{
|
||||
return a * b + c;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType div(genType const & a, genType const & b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
template <typename genTypeT, typename genTypeU, typename genTypeV>
|
||||
GLM_FUNC_QUALIFIER genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c)
|
||||
{
|
||||
return a * b + c;
|
||||
}
|
||||
}//namespace glm
|
||||
|
275
glm/gtx/wrap.inl
275
glm/gtx/wrap.inl
@ -10,157 +10,156 @@
|
||||
// - GLM core
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType clamp
|
||||
(
|
||||
genType const & Texcoord
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return glm::clamp(Texcoord, genType(0), genType(1));
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType clamp
|
||||
(
|
||||
genType const & Texcoord
|
||||
)
|
||||
{
|
||||
return glm::clamp(Texcoord, genType(0), genType(1));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> clamp
|
||||
(
|
||||
detail::tvec2<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec2<T> Result;
|
||||
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
|
||||
Result[i] = clamp(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> clamp
|
||||
(
|
||||
detail::tvec2<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec2<T> Result;
|
||||
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
|
||||
Result[i] = clamp(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> clamp
|
||||
(
|
||||
detail::tvec3<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result;
|
||||
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
|
||||
Result[i] = clamp(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> clamp
|
||||
(
|
||||
detail::tvec3<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result;
|
||||
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
|
||||
Result[i] = clamp(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> clamp
|
||||
(
|
||||
detail::tvec4<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result;
|
||||
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
|
||||
Result[i] = clamp(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> clamp
|
||||
(
|
||||
detail::tvec4<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result;
|
||||
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
|
||||
Result[i] = clamp(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// repeat
|
||||
////////////////////////
|
||||
// repeat
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType repeat
|
||||
(
|
||||
genType const & Texcoord
|
||||
)
|
||||
{
|
||||
return glm::fract(Texcoord);
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType repeat
|
||||
(
|
||||
genType const & Texcoord
|
||||
)
|
||||
{
|
||||
return glm::fract(Texcoord);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> repeat
|
||||
(
|
||||
detail::tvec2<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec2<T> Result;
|
||||
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
|
||||
Result[i] = repeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> repeat
|
||||
(
|
||||
detail::tvec2<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec2<T> Result;
|
||||
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
|
||||
Result[i] = repeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> repeat
|
||||
(
|
||||
detail::tvec3<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result;
|
||||
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
|
||||
Result[i] = repeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> repeat
|
||||
(
|
||||
detail::tvec3<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result;
|
||||
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
|
||||
Result[i] = repeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> repeat
|
||||
(
|
||||
detail::tvec4<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result;
|
||||
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
|
||||
Result[i] = repeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> repeat
|
||||
(
|
||||
detail::tvec4<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result;
|
||||
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
|
||||
Result[i] = repeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// mirrorRepeat
|
||||
////////////////////////
|
||||
// mirrorRepeat
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType mirrorRepeat
|
||||
(
|
||||
genType const & Texcoord
|
||||
)
|
||||
{
|
||||
genType const Clamp = genType(int(glm::floor(Texcoord)) % 2);
|
||||
genType const Floor = glm::floor(Texcoord);
|
||||
genType const Rest = Texcoord - Floor;
|
||||
genType const Mirror = Clamp + Rest;
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType mirrorRepeat
|
||||
(
|
||||
genType const & Texcoord
|
||||
)
|
||||
{
|
||||
genType const Clamp = genType(int(glm::floor(Texcoord)) % 2);
|
||||
genType const Floor = glm::floor(Texcoord);
|
||||
genType const Rest = Texcoord - Floor;
|
||||
genType const Mirror = Clamp + Rest;
|
||||
|
||||
genType Out;
|
||||
if(Mirror >= genType(1))
|
||||
Out = genType(1) - Rest;
|
||||
else
|
||||
Out = Rest;
|
||||
return Out;
|
||||
}
|
||||
genType Out;
|
||||
if(Mirror >= genType(1))
|
||||
Out = genType(1) - Rest;
|
||||
else
|
||||
Out = Rest;
|
||||
return Out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> mirrorRepeat
|
||||
(
|
||||
detail::tvec2<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec2<T> Result;
|
||||
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
|
||||
Result[i] = mirrorRepeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> mirrorRepeat
|
||||
(
|
||||
detail::tvec2<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec2<T> Result;
|
||||
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
|
||||
Result[i] = mirrorRepeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> mirrorRepeat
|
||||
(
|
||||
detail::tvec3<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result;
|
||||
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
|
||||
Result[i] = mirrorRepeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> mirrorRepeat
|
||||
(
|
||||
detail::tvec4<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result;
|
||||
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
|
||||
Result[i] = mirrorRepeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> mirrorRepeat
|
||||
(
|
||||
detail::tvec3<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result;
|
||||
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
|
||||
Result[i] = mirrorRepeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> mirrorRepeat
|
||||
(
|
||||
detail::tvec4<T> const & Texcoord
|
||||
)
|
||||
{
|
||||
detail::tvec4<T> Result;
|
||||
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
|
||||
Result[i] = mirrorRepeat(Texcoord[i]);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
Loading…
x
Reference in New Issue
Block a user