///////////////////////////////////////////////////////////////////////////////////
/// 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_dual_quaternion
/// @file glm/gtx/dual_quaternion.inl
/// @date 2013-02-10 / 2013-02-13
/// @author Maksim Vorobiev (msomeone@gmail.com)
///////////////////////////////////////////////////////////////////////////////////
#include “../geometric.hpp” namespace glm # ifdef GLM_FORCE_SIZE_FUNC template template template template ////////////////////////////////////// template template template template ////////////////////////////////////////////////////////////// template template template ////////////////////////////////////////////////////////////// template template template template ////////////////////////////////////////////////////////////// template template template // Transformation template template template template template template ////////////////////////////////////// template //////////////////////////////////////////////////////// template template template template tquat T const xy = r.x * x.real.y; tvec4 tvec4 tvec4 return tmat3x4 template template T const trace = x[0].x + x[1].y + x[2].z; tquat
#include
{
//////////////////////////////////////
// Component accesses
template
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tdualquat
{
return 2;
}
GLM_FUNC_QUALIFIER typename tdualquat
{
assert(i >= 0 && static_cast
GLM_FUNC_QUALIFIER typename tdualquat
{
assert(i >= 0 && static_cast
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tdualquat
{
return 2;
}
GLM_FUNC_QUALIFIER typename tdualquat
{
assert(i >= 0 && static_cast
GLM_FUNC_QUALIFIER typename tdualquat
{
assert(i >= 0 && static_cast
GLM_FUNC_QUALIFIER tdualquat
# ifndef GLM_FORCE_NO_CTOR_INIT
: real(tquat
, dual(tquat
# endif
{}
GLM_FUNC_QUALIFIER tdualquat
: real(d.real)
, dual(d.dual)
{}
template
: real(d.real)
, dual(d.dual)
{}
// Explicit basic constructors
GLM_FUNC_QUALIFIER tdualquat
{}
GLM_FUNC_QUALIFIER tdualquat
: real(r), dual(tquat
{}
GLM_FUNC_QUALIFIER tdualquat
: real(q), dual(
T(-0.5) * ( p.x*q.x + p.y*q.y + p.z*q.z),
T(+0.5) * ( p.x*q.w + p.y*q.z – p.z*q.y),
T(+0.5) * (-p.x*q.z + p.y*q.w + p.z*q.x),
T(+0.5) * ( p.x*q.y – p.y*q.x + p.z*q.w))
{}
GLM_FUNC_QUALIFIER tdualquat
: real(r), dual(d)
{}
// tdualquat conversions
template
GLM_FUNC_QUALIFIER tdualquat
: real(q.real)
, dual(q.dual)
{}
GLM_FUNC_QUALIFIER tdualquat
{
*this = dualquat_cast(m);
}
GLM_FUNC_QUALIFIER tdualquat
{
*this = dualquat_cast(m);
}
// tdualquat operators
GLM_FUNC_QUALIFIER tdualquat
{
this->real = q.real;
this->dual = q.dual;
return *this;
}
template
GLM_FUNC_QUALIFIER tdualquat
{
this->real = q.real;
this->dual = q.dual;
return *this;
}
template
GLM_FUNC_QUALIFIER tdualquat
{
this->real *= static_cast
this->dual *= static_cast
return *this;
}
template
GLM_FUNC_QUALIFIER tdualquat
{
this->real /= static_cast
this->dual /= static_cast
return *this;
}
// tquat
GLM_FUNC_QUALIFIER tdualquat
{
return tdualquat
}
GLM_FUNC_QUALIFIER tdualquat
{
return tdualquat
}
GLM_FUNC_QUALIFIER tdualquat
{
return tdualquat
}
template
GLM_FUNC_QUALIFIER tvec3
{
tvec3
tvec3
return (cross(real_v3, cross(real_v3,v) + v * q.real.w + dual_v3) + dual_v3 * q.real.w – real_v3 * q.dual.w) * T(2) + v;
}
GLM_FUNC_QUALIFIER tvec3
{
return glm::inverse(q) * v;
}
GLM_FUNC_QUALIFIER tvec4
{
return tvec4
}
GLM_FUNC_QUALIFIER tvec4
{
return glm::inverse(q) * v;
}
GLM_FUNC_QUALIFIER tdualquat
{
return tdualquat
}
GLM_FUNC_QUALIFIER tdualquat
{
return q * s;
}
GLM_FUNC_QUALIFIER tdualquat
{
return tdualquat
}
// Boolean operators
template
GLM_FUNC_QUALIFIER bool operator==(tdualquat
{
return (q1.real == q2.real) && (q1.dual == q2.dual);
}
GLM_FUNC_QUALIFIER bool operator!=(tdualquat
{
return (q1.real != q2.dual) || (q1.real != q2.dual);
}
template
GLM_FUNC_QUALIFIER tdualquat
{
return q / length(q.real);
}
GLM_FUNC_QUALIFIER tdualquat
{
// Dual Quaternion Linear blend aka DLB:
// Lerp is only defined in [0, 1]
assert(a >= static_cast
assert(a <= static_cast
T const k = dot(x.real,y.real) < static_cast
T const one(1);
return tdualquat
}
GLM_FUNC_QUALIFIER tdualquat
{
const glm::tquat
const glm::tquat
return tdualquat
}
GLM_FUNC_QUALIFIER tmat2x4
{
return tmat2x4
}
GLM_FUNC_QUALIFIER tmat3x4
{
tquat
r *= static_cast
T const xz = r.x * x.real.z;
T const yz = r.y * x.real.z;
T const wx = r.w * x.real.x;
T const wy = r.w * x.real.y;
T const wz = r.w * x.real.z;
rr.w + rr.x – rr.y – rr.z,
xy – wz,
xz + wy,
-(x.dual.w * r.x – x.dual.x * r.w + x.dual.y * r.z – x.dual.z * r.y));
xy + wz,
rr.w + rr.y – rr.x – rr.z,
yz – wx,
-(x.dual.w * r.y – x.dual.x * r.z – x.dual.y * r.w + x.dual.z * r.x));
xz – wy,
yz + wx,
rr.w + rr.z – rr.x – rr.y,
-(x.dual.w * r.z + x.dual.x * r.y – x.dual.y * r.x – x.dual.z * r.w));
}
GLM_FUNC_QUALIFIER tdualquat
{
return tdualquat
tquat
tquat
}
GLM_FUNC_QUALIFIER tdualquat
{
tquat
if(trace > static_cast
{
T const r = sqrt(T(1) + trace);
T const invr = static_cast
real.w = static_cast
real.x = (x[2].y – x[1].z) * invr;
real.y = (x[0].z – x[2].x) * invr;
real.z = (x[1].x – x[0].y) * invr;
}
else if(x[0].x > x[1].y && x[0].x > x[2].z)
{
T const r = sqrt(T(1) + x[0].x – x[1].y – x[2].z);
T const invr = static_cast
real.x = static_cast
real.y = (x[1].x + x[0].y) * invr;
real.z = (x[0].z + x[2].x) * invr;
real.w = (x[2].y – x[1].z) * invr;
}
else if(x[1].y > x[2].z)
{
T const r = sqrt(T(1) + x[1].y – x[0].x – x[2].z);
T const invr = static_cast
real.x = (x[1].x + x[0].y) * invr;
real.y = static_cast
real.z = (x[2].y + x[1].z) * invr;
real.w = (x[0].z – x[2].x) * invr;
}
else
{
T const r = sqrt(T(1) + x[2].z – x[0].x – x[1].y);
T const invr = static_cast
real.x = (x[0].z + x[2].x) * invr;
real.y = (x[2].y + x[1].z) * invr;
real.z = static_cast
real.w = (x[1].x – x[0].y) * invr;
}
dual.x = static_cast
dual.y = static_cast
dual.z = static_cast
dual.w = -static_cast
return tdualquat
}
}//namespace glm