Commit 6e54b394 authored by Nianchen Deng's avatar Nianchen Deng
Browse files

paper committed

parent 90553bac
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_interpolation
/// @file glm/gtx/matrix_interpolation.hpp
/// @date 2011-03-05 / 2011-03-05
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER void axisAngle
(
tmat4x4<T, P> const & mat,
tvec3<T, P> & axis,
T & angle
)
{
T epsilon = (T)0.01;
T epsilon2 = (T)0.1;
if((abs(mat[1][0] - mat[0][1]) < epsilon) && (abs(mat[2][0] - mat[0][2]) < epsilon) && (abs(mat[2][1] - mat[1][2]) < epsilon))
{
if ((abs(mat[1][0] + mat[0][1]) < epsilon2) && (abs(mat[2][0] + mat[0][2]) < epsilon2) && (abs(mat[2][1] + mat[1][2]) < epsilon2) && (abs(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 = static_cast<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, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> axisAngleMatrix
(
tvec3<T, P> const & axis,
T const angle
)
{
T c = cos(angle);
T s = sin(angle);
T t = static_cast<T>(1) - c;
tvec3<T, P> n = normalize(axis);
return tmat4x4<T, P>(
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, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> extractMatrixRotation
(
tmat4x4<T, P> const & mat
)
{
return tmat4x4<T, P>(
mat[0][0], mat[0][1], mat[0][2], 0.0,
mat[1][0], mat[1][1], mat[1][2], 0.0,
mat[2][0], mat[2][1], mat[2][2], 0.0,
0.0, 0.0, 0.0, 1.0
);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> interpolate
(
tmat4x4<T, P> const & m1,
tmat4x4<T, P> const & m2,
T const delta
)
{
tmat4x4<T, P> m1rot = extractMatrixRotation(m1);
tmat4x4<T, P> dltRotation = m2 * transpose(m1rot);
tvec3<T, P> dltAxis;
T dltAngle;
axisAngle(dltRotation, dltAxis, dltAngle);
tmat4x4<T, P> out = axisAngleMatrix(dltAxis, dltAngle * delta) * m1rot;
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
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_major_storage
/// @file glm/gtx/matrix_major_storage.hpp
/// @date 2006-04-19 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_matrix_major_storage GLM_GTX_matrix_major_storage
/// @ingroup gtx
///
/// @brief Build matrices with specific matrix order, row or column
///
/// <glm/gtx/matrix_major_storage.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_matrix_major_storage extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_major_storage
/// @{
//! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> rowMajor2(
tvec2<T, P> const & v1,
tvec2<T, P> const & v2);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> rowMajor2(
tmat2x2<T, P> const & m);
//! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> rowMajor3(
tvec3<T, P> const & v1,
tvec3<T, P> const & v2,
tvec3<T, P> const & v3);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> rowMajor3(
tmat3x3<T, P> const & m);
//! Build a row major matrix from row vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> rowMajor4(
tvec4<T, P> const & v1,
tvec4<T, P> const & v2,
tvec4<T, P> const & v3,
tvec4<T, P> const & v4);
//! Build a row major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> rowMajor4(
tmat4x4<T, P> const & m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> colMajor2(
tvec2<T, P> const & v1,
tvec2<T, P> const & v2);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> colMajor2(
tmat2x2<T, P> const & m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> colMajor3(
tvec3<T, P> const & v1,
tvec3<T, P> const & v2,
tvec3<T, P> const & v3);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> colMajor3(
tmat3x3<T, P> const & m);
//! Build a column major matrix from column vectors.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> colMajor4(
tvec4<T, P> const & v1,
tvec4<T, P> const & v2,
tvec4<T, P> const & v3,
tvec4<T, P> const & v4);
//! Build a column major matrix from other matrix.
//! From GLM_GTX_matrix_major_storage extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> colMajor4(
tmat4x4<T, P> const & m);
/// @}
}//namespace glm
#include "matrix_major_storage.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_major_storage
/// @file glm/gtx/matrix_major_storage.hpp
/// @date 2006-04-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> rowMajor2
(
tvec2<T, P> const & v1,
tvec2<T, P> const & v2
)
{
tmat2x2<T, P> 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, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> rowMajor2(
const tmat2x2<T, P>& m)
{
tmat2x2<T, P> 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, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> rowMajor3(
const tvec3<T, P>& v1,
const tvec3<T, P>& v2,
const tvec3<T, P>& v3)
{
tmat3x3<T, P> 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, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> rowMajor3(
const tmat3x3<T, P>& m)
{
tmat3x3<T, P> 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, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> rowMajor4(
const tvec4<T, P>& v1,
const tvec4<T, P>& v2,
const tvec4<T, P>& v3,
const tvec4<T, P>& v4)
{
tmat4x4<T, P> 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, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> rowMajor4(
const tmat4x4<T, P>& m)
{
tmat4x4<T, P> 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, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> colMajor2(
const tvec2<T, P>& v1,
const tvec2<T, P>& v2)
{
return tmat2x2<T, P>(v1, v2);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> colMajor2(
const tmat2x2<T, P>& m)
{
return tmat2x2<T, P>(m);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> colMajor3(
const tvec3<T, P>& v1,
const tvec3<T, P>& v2,
const tvec3<T, P>& v3)
{
return tmat3x3<T, P>(v1, v2, v3);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> colMajor3(
const tmat3x3<T, P>& m)
{
return tmat3x3<T, P>(m);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> colMajor4(
const tvec4<T, P>& v1,
const tvec4<T, P>& v2,
const tvec4<T, P>& v3,
const tvec4<T, P>& v4)
{
return tmat4x4<T, P>(v1, v2, v3, v4);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> colMajor4(
const tmat4x4<T, P>& m)
{
return tmat4x4<T, P>(m);
}
}//namespace glm
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_operation
/// @file glm/gtx/matrix_operation.hpp
/// @date 2009-08-29 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
///
/// @defgroup gtx_matrix_operation GLM_GTX_matrix_operation
/// @ingroup gtx
///
/// @brief Build diagonal matrices from vectors.
///
/// <glm/gtx/matrix_operation.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_matrix_operation extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_operation
/// @{
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> diagonal2x2(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> diagonal2x3(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> diagonal2x4(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x2<T, P> diagonal3x2(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> diagonal3x3(
tvec3<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> diagonal3x4(
tvec3<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x2<T, P> diagonal4x2(
tvec2<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> diagonal4x3(
tvec3<T, P> const & v);
//! Build a diagonal matrix.
//! From GLM_GTX_matrix_operation extension.
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> diagonal4x4(
tvec4<T, P> const & v);
/// @}
}//namespace glm
#include "matrix_operation.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_operation
/// @file glm/gtx/matrix_operation.inl
/// @date 2009-08-29 / 2009-08-29
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> diagonal2x2
(
tvec2<T, P> const & v
)
{
tmat2x2<T, P> Result(static_cast<T>(1));
Result[0][0] = v[0];
Result[1][1] = v[1];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> diagonal2x3
(
tvec2<T, P> const & v
)
{
tmat2x3<T, P> Result(static_cast<T>(1));
Result[0][0] = v[0];
Result[1][1] = v[1];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> diagonal2x4
(
tvec2<T, P> const & v
)
{
tmat2x4<T, P> Result(static_cast<T>(1));
Result[0][0] = v[0];
Result[1][1] = v[1];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> diagonal3x2
(
tvec2<T, P> const & v
)
{
tmat3x2<T, P> Result(static_cast<T>(1));
Result[0][0] = v[0];
Result[1][1] = v[1];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> diagonal3x3
(
tvec3<T, P> const & v
)
{
tmat3x3<T, P> Result(static_cast<T>(1));
Result[0][0] = v[0];
Result[1][1] = v[1];
Result[2][2] = v[2];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> diagonal3x4
(
tvec3<T, P> const & v
)
{
tmat3x4<T, P> Result(static_cast<T>(1));
Result[0][0] = v[0];
Result[1][1] = v[1];
Result[2][2] = v[2];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> diagonal4x4
(
tvec4<T, P> const & v
)
{
tmat4x4<T, P> Result(static_cast<T>(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 T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> diagonal4x3
(
tvec3<T, P> const & v
)
{
tmat4x3<T, P> Result(static_cast<T>(1));
Result[0][0] = v[0];
Result[1][1] = v[1];
Result[2][2] = v[2];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> diagonal4x2
(
tvec2<T, P> const & v
)
{
tmat4x2<T, P> Result(static_cast<T>(1));
Result[0][0] = v[0];
Result[1][1] = v[1];
return Result;
}
}//namespace glm
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_query
/// @file glm/gtx/matrix_query.hpp
/// @date 2007-03-05 / 2011-08-28
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_vector_query (dependence)
///
/// @defgroup gtx_matrix_query GLM_GTX_matrix_query
/// @ingroup gtx
///
/// @brief Query to evaluate matrix properties
///
/// <glm/gtx/matrix_query.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtx/vector_query.hpp"
#include <limits>
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_matrix_query extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_query
/// @{
/// Return whether a matrix a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
GLM_FUNC_DECL bool isNull(tmat2x2<T, P> const & m, T const & epsilon);
/// Return whether a matrix a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
GLM_FUNC_DECL bool isNull(tmat3x3<T, P> const & m, T const & epsilon);
/// Return whether a matrix is a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
GLM_FUNC_DECL bool isNull(tmat4x4<T, P> const & m, T const & epsilon);
/// Return whether a matrix is an identity matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P, template <typename, precision> class matType>
GLM_FUNC_DECL bool isIdentity(matType<T, P> const & m, T const & epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
GLM_FUNC_DECL bool isNormalized(tmat2x2<T, P> const & m, T const & epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
GLM_FUNC_DECL bool isNormalized(tmat3x3<T, P> const & m, T const & epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
GLM_FUNC_DECL bool isNormalized(tmat4x4<T, P> const & m, T const & epsilon);
/// Return whether a matrix is an orthonormalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P, template <typename, precision> class matType>
GLM_FUNC_DECL bool isOrthogonal(matType<T, P> const & m, T const & epsilon);
/// @}
}//namespace glm
#include "matrix_query.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_query
/// @file glm/gtx/matrix_query.inl
/// @date 2007-03-05 / 2007-03-05
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template<typename T, precision P>
GLM_FUNC_QUALIFIER bool isNull(tmat2x2<T, P> const & m, T const & epsilon)
{
bool result = true;
for(detail::component_count_t i = 0; result && i < 2 ; ++i)
result = isNull(m[i], epsilon);
return result;
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER bool isNull(tmat3x3<T, P> const & m, T const & epsilon)
{
bool result = true;
for(detail::component_count_t i = 0; result && i < 3 ; ++i)
result = isNull(m[i], epsilon);
return result;
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER bool isNull(tmat4x4<T, P> const & m, T const & epsilon)
{
bool result = true;
for(detail::component_count_t i = 0; result && i < 4 ; ++i)
result = isNull(m[i], epsilon);
return result;
}
template<typename T, precision P, template <typename, precision> class matType>
GLM_FUNC_QUALIFIER bool isIdentity(matType<T, P> const & m, T const & epsilon)
{
bool result = true;
for(detail::component_count_t i(0); result && i < detail::component_count(m[0]); ++i)
{
for(detail::component_count_t j(0); result && j < i ; ++j)
result = abs(m[i][j]) <= epsilon;
if(result)
result = abs(m[i][i] - 1) <= epsilon;
for(detail::component_count_t j(i + 1); result && j < detail::component_count(m); ++j)
result = abs(m[i][j]) <= epsilon;
}
return result;
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER bool isNormalized(tmat2x2<T, P> const & m, T const & epsilon)
{
bool result(true);
for(detail::component_count_t i(0); result && i < detail::component_count(m); ++i)
result = isNormalized(m[i], epsilon);
for(detail::component_count_t i(0); result && i < detail::component_count(m); ++i)
{
typename tmat2x2<T, P>::col_type v;
for(detail::component_count_t j(0); j < detail::component_count(m); ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER bool isNormalized(tmat3x3<T, P> const & m, T const & epsilon)
{
bool result(true);
for(detail::component_count_t i(0); result && i < detail::component_count(m); ++i)
result = isNormalized(m[i], epsilon);
for(detail::component_count_t i(0); result && i < detail::component_count(m); ++i)
{
typename tmat3x3<T, P>::col_type v;
for(detail::component_count_t j(0); j < detail::component_count(m); ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER bool isNormalized(tmat4x4<T, P> const & m, T const & epsilon)
{
bool result(true);
for(detail::component_count_t i(0); result && i < detail::component_count(m); ++i)
result = isNormalized(m[i], epsilon);
for(detail::component_count_t i(0); result && i < detail::component_count(m); ++i)
{
typename tmat4x4<T, P>::col_type v;
for(detail::component_count_t j(0); j < detail::component_count(m); ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename T, precision P, template <typename, precision> class matType>
GLM_FUNC_QUALIFIER bool isOrthogonal(matType<T, P> const & m, T const & epsilon)
{
bool result(true);
for(detail::component_count_t i(0); result && i < detail::component_count(m) - 1; ++i)
for(detail::component_count_t j(i + 1); result && j < detail::component_count(m); ++j)
result = areOrthogonal(m[i], m[j], epsilon);
if(result)
{
matType<T, P> tmp = transpose(m);
for(detail::component_count_t i(0); result && i < detail::component_count(m) - 1 ; ++i)
for(detail::component_count_t j(i + 1); result && j < detail::component_count(m); ++j)
result = areOrthogonal(tmp[i], tmp[j], epsilon);
}
return result;
}
}//namespace glm
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_transform_2d
/// @file glm/gtx/matrix_transform_2d.hpp
/// @date 2014-02-20
/// @author Miguel Ángel Pérez Martínez
///
/// @see core (dependence)
///
/// @defgroup gtx_matrix_transform_2d GLM_GTX_matrix_transform_2d
/// @ingroup gtx
///
/// @brief Defines functions that generate common 2d transformation matrices.
///
/// <glm/gtx/matrix_transform_2d.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../mat3x3.hpp"
#include "../vec2.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_matrix_transform_2d extension included")
#endif
namespace glm
{
/// @addtogroup gtx_matrix_transform_2d
/// @{
/// Builds a translation 3 * 3 matrix created from a vector of 2 components.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param v Coordinates of a translation vector.
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> translate(
tmat3x3<T, P> const & m,
tvec2<T, P> const & v);
/// Builds a rotation 3 * 3 matrix created from an angle.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param angle Rotation angle expressed in radians if GLM_FORCE_RADIANS is defined or degrees otherwise.
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> rotate(
tmat3x3<T, P> const & m,
T angle);
/// Builds a scale 3 * 3 matrix created from a vector of 2 components.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param v Coordinates of a scale vector.
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> scale(
tmat3x3<T, P> const & m,
tvec2<T, P> const & v);
/// Builds an horizontal (parallel to the x axis) shear 3 * 3 matrix.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param y Shear factor.
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> shearX(
tmat3x3<T, P> const & m,
T y);
/// Builds a vertical (parallel to the y axis) shear 3 * 3 matrix.
///
/// @param m Input matrix multiplied by this translation matrix.
/// @param x Shear factor.
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> shearY(
tmat3x3<T, P> const & m,
T x);
/// @}
}//namespace glm
#include "matrix_transform_2d.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_matrix_transform_2d
/// @file glm/gtc/matrix_transform_2d.inl
/// @date 2014-02-20
/// @author Miguel Ángel Pérez Martínez
///////////////////////////////////////////////////////////////////////////////////
#include "../trigonometric.hpp"
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> translate(
tmat3x3<T, P> const & m,
tvec2<T, P> const & v)
{
tmat3x3<T, P> Result(m);
Result[2] = m[0] * v[0] + m[1] * v[1] + m[2];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> rotate(
tmat3x3<T, P> const & m,
T angle)
{
T const a = angle;
T const c = cos(a);
T const s = sin(a);
tmat3x3<T, P> Result(uninitialize);
Result[0] = m[0] * c + m[1] * s;
Result[1] = m[0] * -s + m[1] * c;
Result[2] = m[2];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> scale(
tmat3x3<T, P> const & m,
tvec2<T, P> const & v)
{
tmat3x3<T, P> Result(uninitialize);
Result[0] = m[0] * v[0];
Result[1] = m[1] * v[1];
Result[2] = m[2];
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> shearX(
tmat3x3<T, P> const & m,
T y)
{
tmat3x3<T, P> Result(1);
Result[0][1] = y;
return m * Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> shearY(
tmat3x3<T, P> const & m,
T x)
{
tmat3x3<T, P> Result(1);
Result[1][0] = x;
return m * Result;
}
}//namespace glm
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_mixed_product
/// @file glm/gtx/mixed_product.hpp
/// @date 2007-04-03 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
///
/// @defgroup gtx_mixed_product GLM_GTX_mixed_producte
/// @ingroup gtx
///
/// @brief Mixed product of 3 vectors.
///
/// <glm/gtx/mixed_product.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_mixed_product extension included")
#endif
namespace glm
{
/// @addtogroup gtx_mixed_product
/// @{
/// @brief Mixed product of 3 vectors (from GLM_GTX_mixed_product extension)
template <typename T, precision P>
GLM_FUNC_DECL T mixedProduct(
tvec3<T, P> const & v1,
tvec3<T, P> const & v2,
tvec3<T, P> const & v3);
/// @}
}// namespace glm
#include "mixed_product.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_mixed_product
/// @file glm/gtx/mixed_product.inl
/// @date 2007-04-03 / 2008-09-17
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER T mixedProduct
(
tvec3<T, P> const & v1,
tvec3<T, P> const & v2,
tvec3<T, P> const & v3
)
{
return dot(cross(v1, v2), v3);
}
}//namespace glm
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_multiple
/// @file glm/gtx/multiple.hpp
/// @date 2009-10-26 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_multiple GLM_GTX_multiple
/// @ingroup gtx
///
/// @brief Find the closest number of a number multiple of other number.
///
/// <glm/gtx/multiple.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../gtc/round.hpp"
#pragma message("GLM: GLM_GTX_multiple extension is deprecated, use GLM_GTC_round instead.")
namespace glm
{
/// @addtogroup gtx_multiple
/// @{
/// Higher multiple number of Source.
///
/// @tparam genType Floating-point or integer scalar or vector types.
/// @param Source
/// @param Multiple Must be a null or positive value
///
/// @see gtx_multiple
template <typename genType>
GLM_DEPRECATED GLM_FUNC_DECL genType higherMultiple(
genType Source,
genType Multiple);
/// Higher multiple number of Source.
///
/// @tparam genType Floating-point or integer scalar or vector types.
/// @param Source
/// @param Multiple Must be a null or positive value
///
/// @see gtx_multiple
template <typename T, precision P, template <typename, precision> class vecType>
GLM_DEPRECATED GLM_FUNC_DECL vecType<T, P> higherMultiple(
vecType<T, P> const & Source,
vecType<T, P> const & Multiple);
/// Lower multiple number of Source.
///
/// @tparam genType Floating-point or integer scalar or vector types.
/// @param Source
/// @param Multiple Must be a null or positive value
///
/// @see gtx_multiple
template <typename genType>
GLM_DEPRECATED GLM_FUNC_DECL genType lowerMultiple(
genType Source,
genType Multiple);
/// Lower multiple number of Source.
///
/// @tparam genType Floating-point or integer scalar or vector types.
/// @param Source
/// @param Multiple Must be a null or positive value
///
/// @see gtx_multiple
template <typename T, precision P, template <typename, precision> class vecType>
GLM_DEPRECATED GLM_FUNC_DECL vecType<T, P> lowerMultiple(
vecType<T, P> const & Source,
vecType<T, P> const & Multiple);
/// @}
}//namespace glm
#include "multiple.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_multiple
/// @file glm/gtx/multiple.inl
/// @date 2009-10-26 / 2011-06-07
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
//////////////////////
// higherMultiple
template <typename genType>
GLM_FUNC_QUALIFIER genType higherMultiple(genType Source, genType Multiple)
{
return detail::compute_ceilMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> higherMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
{
return detail::functor2<T, P, vecType>::call(higherMultiple, Source, Multiple);
}
//////////////////////
// lowerMultiple
template <typename genType>
GLM_FUNC_QUALIFIER genType lowerMultiple(genType Source, genType Multiple)
{
return detail::compute_floorMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> lowerMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
{
return detail::functor2<T, P, vecType>::call(lowerMultiple, Source, Multiple);
}
}//namespace glm
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_norm
/// @file glm/gtx/norm.hpp
/// @date 2005-12-21 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_quaternion (dependence)
///
/// @defgroup gtx_norm GLM_GTX_norm
/// @ingroup gtx
///
/// @brief Various ways to compute vector norms.
///
/// <glm/gtx/norm.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtx/quaternion.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_norm extension included")
#endif
namespace glm
{
/// @addtogroup gtx_norm
/// @{
//! Returns the squared length of x.
//! From GLM_GTX_norm extension.
template <typename T>
GLM_FUNC_DECL T length2(
T const & x);
//! Returns the squared length of x.
//! From GLM_GTX_norm extension.
template <typename genType>
GLM_FUNC_DECL typename genType::value_type length2(
genType const & x);
//! Returns the squared distance between p0 and p1, i.e., length(p0 - p1).
//! From GLM_GTX_norm extension.
template <typename T>
GLM_FUNC_DECL T distance2(
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 genType>
GLM_FUNC_DECL 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, precision P>
GLM_FUNC_DECL T l1Norm(
tvec3<T, P> const & x,
tvec3<T, P> const & y);
//! Returns the L1 norm of v.
//! From GLM_GTX_norm extension.
template <typename T, precision P>
GLM_FUNC_DECL T l1Norm(
tvec3<T, P> const & v);
//! Returns the L2 norm between x and y.
//! From GLM_GTX_norm extension.
template <typename T, precision P>
GLM_FUNC_DECL T l2Norm(
tvec3<T, P> const & x,
tvec3<T, P> const & y);
//! Returns the L2 norm of v.
//! From GLM_GTX_norm extension.
template <typename T, precision P>
GLM_FUNC_DECL T l2Norm(
tvec3<T, P> const & x);
//! Returns the L norm between x and y.
//! From GLM_GTX_norm extension.
template <typename T, precision P>
GLM_FUNC_DECL T lxNorm(
tvec3<T, P> const & x,
tvec3<T, P> const & y,
unsigned int Depth);
//! Returns the L norm of v.
//! From GLM_GTX_norm extension.
template <typename T, precision P>
GLM_FUNC_DECL T lxNorm(
tvec3<T, P> const & x,
unsigned int Depth);
/// @}
}//namespace glm
#include "norm.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_norm
/// @file glm/gtx/norm.inl
/// @date 2005-12-21 / 2008-07-24
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER T length2
(
T const & x
)
{
return x * x;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T length2
(
tvec2<T, P> const & x
)
{
return dot(x, x);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T length2
(
tvec3<T, P> const & x
)
{
return dot(x, x);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T length2
(
tvec4<T, P> const & x
)
{
return dot(x, x);
}
template <typename T>
GLM_FUNC_QUALIFIER T distance2
(
T const & p0,
T const & p1
)
{
return length2(p1 - p0);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T distance2
(
tvec2<T, P> const & p0,
tvec2<T, P> const & p1
)
{
return length2(p1 - p0);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T distance2
(
tvec3<T, P> const & p0,
tvec3<T, P> const & p1
)
{
return length2(p1 - p0);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T distance2
(
tvec4<T, P> const & p0,
tvec4<T, P> const & p1
)
{
return length2(p1 - p0);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T l1Norm
(
tvec3<T, P> const & a,
tvec3<T, P> const & b
)
{
return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T l1Norm
(
tvec3<T, P> const & v
)
{
return abs(v.x) + abs(v.y) + abs(v.z);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T l2Norm
(
tvec3<T, P> const & a,
tvec3<T, P> const & b
)
{
return length(b - a);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T l2Norm
(
tvec3<T, P> const & v
)
{
return length(v);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T lxNorm
(
tvec3<T, P> const & x,
tvec3<T, P> 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, precision P>
GLM_FUNC_QUALIFIER T lxNorm
(
tvec3<T, P> 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
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_normal
/// @file glm/gtx/normal.hpp
/// @date 2005-12-21 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_extented_min_max (dependence)
///
/// @defgroup gtx_normal GLM_GTX_normal
/// @ingroup gtx
///
/// @brief Compute the normal of a triangle.
///
/// <glm/gtx/normal.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_normal extension included")
#endif
namespace glm
{
/// @addtogroup gtx_normal
/// @{
//! Computes triangle normal from triangle points.
//! From GLM_GTX_normal extension.
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> triangleNormal(
tvec3<T, P> const & p1,
tvec3<T, P> const & p2,
tvec3<T, P> const & p3);
/// @}
}//namespace glm
#include "normal.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_normal
/// @file glm/gtx/normal.inl
/// @date 2005-12-21 / 2011-06-07
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> triangleNormal
(
tvec3<T, P> const & p1,
tvec3<T, P> const & p2,
tvec3<T, P> const & p3
)
{
return normalize(cross(p1 - p2, p1 - p3));
}
}//namespace glm
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_normalize_dot
/// @file glm/gtx/normalize_dot.hpp
/// @date 2007-09-28 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtx_fast_square_root (dependence)
///
/// @defgroup gtx_normalize_dot GLM_GTX_normalize_dot
/// @ingroup gtx
///
/// @brief Dot product of vectors that need to be normalize with a single square root.
///
/// <glm/gtx/normalized_dot.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../gtx/fast_square_root.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_normalize_dot extension included")
#endif
namespace glm
{
/// @addtogroup gtx_normalize_dot
/// @{
/// Normalize parameters and returns the dot product of x and y.
/// It's faster that dot(normalize(x), normalize(y)).
///
/// @see gtx_normalize_dot extension.
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL T normalizeDot(vecType<T, P> const & x, vecType<T, P> const & y);
/// Normalize parameters and returns the dot product of x and y.
/// Faster that dot(fastNormalize(x), fastNormalize(y)).
///
/// @see gtx_normalize_dot extension.
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL T fastNormalizeDot(vecType<T, P> const & x, vecType<T, P> const & y);
/// @}
}//namespace glm
#include "normalize_dot.inl"
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_normalize_dot
/// @file glm/gtx/normalize_dot.inl
/// @date 2007-09-28 / 2008-10-07
/// @author Christophe Riccio
//////////////////////////////////////////////////////////////////////////////////
namespace glm
{
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER T normalizeDot(vecType<T, P> const & x, vecType<T, P> const & y)
{
return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER T fastNormalizeDot(vecType<T, P> const & x, vecType<T, P> const & y)
{
return glm::dot(x, y) * glm::fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y));
}
}//namespace glm
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref gtx_number_precision
/// @file glm/gtx/number_precision.hpp
/// @date 2007-05-10 / 2011-06-07
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtc_type_precision (dependence)
/// @see gtc_quaternion (dependence)
///
/// @defgroup gtx_number_precision GLM_GTX_number_precision
/// @ingroup gtx
///
/// @brief Defined size types.
///
/// <glm/gtx/number_precision.hpp> need to be included to use these functionalities.
///////////////////////////////////////////////////////////////////////////////////
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/type_precision.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTX_number_precision extension included")
#endif
namespace glm{
namespace gtx
{
/////////////////////////////
// Unsigned int vector types
/// @addtogroup gtx_number_precision
/// @{
typedef u8 u8vec1; //!< \brief 8bit unsigned integer scalar. (from GLM_GTX_number_precision extension)
typedef u16 u16vec1; //!< \brief 16bit unsigned integer scalar. (from GLM_GTX_number_precision extension)
typedef u32 u32vec1; //!< \brief 32bit unsigned integer scalar. (from GLM_GTX_number_precision extension)
typedef u64 u64vec1; //!< \brief 64bit unsigned integer scalar. (from GLM_GTX_number_precision extension)
//////////////////////
// Float vector types
typedef f32 f32vec1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension)
typedef f64 f64vec1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension)
//////////////////////
// Float matrix types
typedef f32 f32mat1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension)
typedef f32 f32mat1x1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension)
typedef f64 f64mat1; //!< \brief Double-precision floating-point scalar. (from GLM_GTX_number_precision extension)
typedef f64 f64mat1x1; //!< \brief Double-precision floating-point scalar. (from GLM_GTX_number_precision extension)
/// @}
}//namespace gtx
}//namespace glm
#include "number_precision.inl"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment