mirror of
https://github.com/g-truc/glm.git
synced 2024-11-27 02:34:35 +00:00
Fixed dual quaternion build on Clang, fixed space characters #49
This commit is contained in:
parent
7739e9c3e3
commit
6a96cd819a
@ -80,8 +80,8 @@ namespace detail
|
|||||||
explicit tdualquat(tmat3x4<T> const & aug_mat);
|
explicit tdualquat(tmat3x4<T> const & aug_mat);
|
||||||
|
|
||||||
// Accesses
|
// Accesses
|
||||||
typename part_type & operator[](int i);
|
part_type & operator[](int i);
|
||||||
typename part_type const & operator[](int i) const;
|
part_type const & operator[](int i) const;
|
||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
tdualquat<T> & operator*=(value_type const & s);
|
tdualquat<T> & operator*=(value_type const & s);
|
||||||
@ -164,12 +164,15 @@ namespace detail
|
|||||||
detail::tdualquat<T> inverse(
|
detail::tdualquat<T> inverse(
|
||||||
detail::tdualquat<T> const & q);
|
detail::tdualquat<T> const & q);
|
||||||
|
|
||||||
|
/*
|
||||||
/// Extracts a rotation part from dual-quaternion to a 3 * 3 matrix.
|
/// Extracts a rotation part from dual-quaternion to a 3 * 3 matrix.
|
||||||
|
/// TODO
|
||||||
///
|
///
|
||||||
/// @see gtc_dual_quaternion
|
/// @see gtc_dual_quaternion
|
||||||
template <typename T>
|
template <typename T>
|
||||||
detail::tmat3x3<T> mat3_cast(
|
detail::tmat3x3<T> mat3_cast(
|
||||||
detail::tdualquat<T> const & x);
|
detail::tdualquat<T> const & x);
|
||||||
|
*/
|
||||||
|
|
||||||
/// Converts a quaternion to a 2 * 4 matrix.
|
/// Converts a quaternion to a 2 * 4 matrix.
|
||||||
///
|
///
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
/// THE SOFTWARE.
|
/// THE SOFTWARE.
|
||||||
///
|
///
|
||||||
/// @ref gtx_quaternion
|
/// @ref gtx_dual_quaternion
|
||||||
/// @file glm/gtx/quaternion.inl
|
/// @file glm/gtx/dual_quaternion.inl
|
||||||
/// @date 2013-02-10 / 2013-02-13
|
/// @date 2013-02-10 / 2013-02-13
|
||||||
/// @author Maksim Vorobiev (msomeone@gmail.com)
|
/// @author Maksim Vorobiev (msomeone@gmail.com)
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -40,7 +40,7 @@ namespace detail
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER tdualquat<T>::tdualquat() :
|
GLM_FUNC_QUALIFIER tdualquat<T>::tdualquat() :
|
||||||
real(tquat<T>()),
|
real(tquat<T>()),
|
||||||
dual(tquat<T>(tdualquat<T>::value_type(0),tdualquat<T>::value_type(0),tdualquat<T>::value_type(0),tdualquat<T>::value_type(0)))
|
dual(tquat<T>(T(0), T(0), T(0), T(0)))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -49,7 +49,7 @@ namespace detail
|
|||||||
tquat<T> const & r
|
tquat<T> const & r
|
||||||
) :
|
) :
|
||||||
real(r),
|
real(r),
|
||||||
dual(tquat<T>(tdualquat<T>::value_type(0),tdualquat<T>::value_type(0),tdualquat<T>::value_type(0),tdualquat<T>::value_type(0)))
|
dual(tquat<T>(T(0), T(0), T(0), T(0)))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -69,7 +69,8 @@ namespace detail
|
|||||||
tvec3<T> const& p
|
tvec3<T> const& p
|
||||||
) :
|
) :
|
||||||
real(q),
|
real(q),
|
||||||
dual(-0.5f*( p.x*q.x + p.y*q.y + p.z*q.z),
|
dual(
|
||||||
|
-0.5f*( p.x*q.x + p.y*q.y + p.z*q.z),
|
||||||
0.5f*( p.x*q.w + p.y*q.z - p.z*q.y),
|
0.5f*( p.x*q.w + p.y*q.z - p.z*q.y),
|
||||||
0.5f*(-p.x*q.z + p.y*q.w + p.z*q.x),
|
0.5f*(-p.x*q.z + p.y*q.w + p.z*q.x),
|
||||||
0.5f*( p.x*q.y - p.y*q.x + p.z*q.w))
|
0.5f*( p.x*q.y - p.y*q.x + p.z*q.w))
|
||||||
@ -80,10 +81,10 @@ namespace detail
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER tdualquat<T>::tdualquat
|
GLM_FUNC_QUALIFIER tdualquat<T>::tdualquat
|
||||||
(
|
(
|
||||||
tmat2x4<T> const & holder_mat
|
tmat2x4<T> const & m
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
*this = dualquat_cast<>
|
*this = dualquat_cast(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -144,7 +145,7 @@ namespace detail
|
|||||||
detail::tdualquat<T> const & q
|
detail::tdualquat<T> const & q
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tdualquat<T>(-this->real,-this->dual);
|
return detail::tdualquat<T>(-q.real,-q.dual);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -175,9 +176,9 @@ namespace detail
|
|||||||
detail::tvec3<T> const & v
|
detail::tvec3<T> const & v
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const detail::tvec3<T> real_v3(q.real.x,q.real.y,q.real.z);
|
detail::tvec3<T> const real_v3(q.real.x,q.real.y,q.real.z);
|
||||||
const detail::tvec3<T> dual_v3(q.dual.x,q.dual.y,q.dual.z);
|
detail::tvec3<T> const dual_v3(q.dual.x,q.dual.y,q.dual.z);
|
||||||
return (cross(real_v3, cross(real_v3,v) + v * q.real.w + dual_v3) + dual_v3 * q.real.w - real_v3 * q.dual.w) * detail::tdualquat<T>::value_type(2) + v;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -201,9 +202,11 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> operator* (
|
GLM_FUNC_QUALIFIER detail::tvec4<T> operator*
|
||||||
|
(
|
||||||
detail::tvec4<T> const & v,
|
detail::tvec4<T> const & v,
|
||||||
detail::tdualquat<T> const & q)
|
detail::tdualquat<T> const & q
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return inverse(q) * v;
|
return inverse(q) * v;
|
||||||
}
|
}
|
||||||
@ -278,12 +281,13 @@ namespace detail
|
|||||||
detail::tdualquat<T> const & y,
|
detail::tdualquat<T> const & y,
|
||||||
typename detail::tdualquat<T>::value_type const & a
|
typename detail::tdualquat<T>::value_type const & a
|
||||||
)
|
)
|
||||||
{ // Dual Quaternion Linear blend aka DLB:
|
{
|
||||||
|
// Dual Quaternion Linear blend aka DLB:
|
||||||
// Lerp is only defined in [0, 1]
|
// Lerp is only defined in [0, 1]
|
||||||
assert(a >= T(0));
|
assert(a >= T(0));
|
||||||
assert(a <= T(1));
|
assert(a <= T(1));
|
||||||
const detail::tdualquat<T>::value_type k = dot(x.real,y.real) < detail::tdualquat<T>::value_type(0) ? -a : a;
|
T const k = dot(x.real,y.real) < detail::tdualquat<T>::value_type(0) ? -a : a;
|
||||||
const detail::tdualquat<T>::value_type one(1);
|
T const one(1);
|
||||||
return detail::tdualquat<T>(x * (one - a) + y * k);
|
return detail::tdualquat<T>(x * (one - a) + y * k);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +301,7 @@ namespace detail
|
|||||||
const glm::detail::tquat<T> dual = conjugate(q.dual);
|
const glm::detail::tquat<T> dual = conjugate(q.dual);
|
||||||
return detail::tdualquat<T>(real, dual + (real * (-2.0f * dot(real,dual))));
|
return detail::tdualquat<T>(real, dual + (real * (-2.0f * dot(real,dual))));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> mat3_cast
|
GLM_FUNC_QUALIFIER detail::tmat3x3<T> mat3_cast
|
||||||
(
|
(
|
||||||
@ -305,7 +309,7 @@ namespace detail
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat2x4<T> mat2x4_cast
|
GLM_FUNC_QUALIFIER detail::tmat2x4<T> mat2x4_cast
|
||||||
(
|
(
|
||||||
@ -323,36 +327,33 @@ namespace detail
|
|||||||
{
|
{
|
||||||
detail::tquat<T> r = x.real / length2(x.real);
|
detail::tquat<T> r = x.real / length2(x.real);
|
||||||
|
|
||||||
const detail::tquat<T> rr(r.w * x.real.w, r.x * x.real.x, r.y * x.real.y, r.z * x.real.z);
|
detail::tquat<T> const rr(r.w * x.real.w, r.x * x.real.x, r.y * x.real.y, r.z * x.real.z);
|
||||||
r *= detail::tdualquat<T>::value_type(2);
|
r *= T(2);
|
||||||
|
|
||||||
const detail::tdualquat<T>::value_type xy = r.x*d.real.y;
|
T const xy = r.x * x.real.y;
|
||||||
const detail::tdualquat<T>::value_type xz = r.x*d.real.z;
|
T const xz = r.x * x.real.z;
|
||||||
const detail::tdualquat<T>::value_type yz = r.y*d.real.z;
|
T const yz = r.y * x.real.z;
|
||||||
const detail::tdualquat<T>::value_type wx = r.w*d.real.x;
|
T const wx = r.w * x.real.x;
|
||||||
const detail::tdualquat<T>::value_type wy = r.w*d.real.y;
|
T const wy = r.w * x.real.y;
|
||||||
const detail::tdualquat<T>::value_type wz = r.w*d.real.z;
|
T const wz = r.w * x.real.z;
|
||||||
|
|
||||||
const detail::tvec4<T> a(
|
detail::tvec4<T> const a(
|
||||||
rr.w + rr.x - rr.y - rr.z,
|
rr.w + rr.x - rr.y - rr.z,
|
||||||
xy - wz,
|
xy - wz,
|
||||||
xz + wy,
|
xz + wy,
|
||||||
-(x.dual.w * r.x - x.dual.x * r.w + x.dual.y * r.z - x.dual.z * r.y)
|
-(x.dual.w * r.x - x.dual.x * r.w + x.dual.y * r.z - x.dual.z * r.y));
|
||||||
);
|
|
||||||
|
|
||||||
const detail::tvec4<T> b(
|
detail::tvec4<T> const b(
|
||||||
xy + wz,
|
xy + wz,
|
||||||
rr.w + rr.y - rr.x - rr.z,
|
rr.w + rr.y - rr.x - rr.z,
|
||||||
yz - wx,
|
yz - wx,
|
||||||
-(x.dual.w * r.y - x.dual.x * r.z - x.dual.y * r.w + x.dual.z * r.x)
|
-(x.dual.w * r.y - x.dual.x * r.z - x.dual.y * r.w + x.dual.z * r.x));
|
||||||
);
|
|
||||||
|
|
||||||
const detail::tvec4<T> c(
|
detail::tvec4<T> const c(
|
||||||
xz - wy,
|
xz - wy,
|
||||||
yz + wx,
|
yz + wx,
|
||||||
rr.w + rr.z - rr.x - rr.y,
|
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)
|
-(x.dual.w * r.z + x.dual.x * r.y - x.dual.y * r.x - x.dual.z * r.w));
|
||||||
);
|
|
||||||
|
|
||||||
return detail::tmat3x4<T>(a, b, c);
|
return detail::tmat3x4<T>(a, b, c);
|
||||||
}
|
}
|
||||||
@ -363,10 +364,9 @@ namespace detail
|
|||||||
detail::tmat2x4<T> const & x
|
detail::tmat2x4<T> const & x
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tdualquat (
|
return detail::tdualquat<T>(
|
||||||
detail::tquat<T>( x[0].w, x[0].x, x[0].y, x[0].z ),
|
detail::tquat<T>( x[0].w, x[0].x, x[0].y, x[0].z ),
|
||||||
detail::tquat<T> ( x[1].w, x[1].x, x[1].y, x[1].z )
|
detail::tquat<T>( x[1].w, x[1].x, x[1].y, x[1].z ));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -377,11 +377,11 @@ namespace detail
|
|||||||
{
|
{
|
||||||
detail::tquat<T> real;
|
detail::tquat<T> real;
|
||||||
|
|
||||||
const detail::tdualquat<T>::value_type trace = x[0].x + x[1].y + x[2].z;
|
T const trace = x[0].x + x[1].y + x[2].z;
|
||||||
if(trace > detail::tdualquat<T>::value_type(0))
|
if(trace > detail::tdualquat<T>::value_type(0))
|
||||||
{
|
{
|
||||||
const detail::tdualquat<T>::value_type r = sqrt(detail::tdualquat<T>::value_type(1) + trace);
|
T const r = sqrt(detail::tdualquat<T>::value_type(1) + trace);
|
||||||
const detail::tdualquat<T>::value_type invr = detail::tdualquat<T>::value_type(0.5) / r;
|
T const invr = detail::tdualquat<T>::value_type(0.5) / r;
|
||||||
real.w = detail::tdualquat<T>::value_type(0.5) * r;
|
real.w = detail::tdualquat<T>::value_type(0.5) * r;
|
||||||
real.x = (x[2].y - x[1].z) * invr;
|
real.x = (x[2].y - x[1].z) * invr;
|
||||||
real.y = (x[0].z - x[2].x) * invr;
|
real.y = (x[0].z - x[2].x) * invr;
|
||||||
@ -389,8 +389,8 @@ namespace detail
|
|||||||
}
|
}
|
||||||
else if(x[0].x > x[1].y && x[0].x > x[2].z)
|
else if(x[0].x > x[1].y && x[0].x > x[2].z)
|
||||||
{
|
{
|
||||||
const detail::tdualquat<T>::value_type r = sqrt(detail::tdualquat<T>::value_type(1) + x[0].x - x[1].y - x[2].z);
|
T const r = sqrt(detail::tdualquat<T>::value_type(1) + x[0].x - x[1].y - x[2].z);
|
||||||
const detail::tdualquat<T>::value_type invr = detail::tdualquat<T>::value_type(0.5) / r;
|
T const invr = detail::tdualquat<T>::value_type(0.5) / r;
|
||||||
real.x = detail::tdualquat<T>::value_type(0.5)*r;
|
real.x = detail::tdualquat<T>::value_type(0.5)*r;
|
||||||
real.y = (x[1].x + x[0].y) * invr;
|
real.y = (x[1].x + x[0].y) * invr;
|
||||||
real.z = (x[0].z + x[2].x) * invr;
|
real.z = (x[0].z + x[2].x) * invr;
|
||||||
@ -398,28 +398,28 @@ namespace detail
|
|||||||
}
|
}
|
||||||
else if(x[1].y > x[2].z)
|
else if(x[1].y > x[2].z)
|
||||||
{
|
{
|
||||||
const detail::tdualquat<T>::value_type r = sqrt(detail::tdualquat<T>::value_type(1) + x[1].y - x[0].x - x[2].z);
|
T const r = sqrt(T(1) + x[1].y - x[0].x - x[2].z);
|
||||||
const detail::tdualquat<T>::value_type invr = detail::tdualquat<T>::value_type(0.5) / r;
|
T const invr = T(0.5) / r;
|
||||||
x = (x[1].x + x[0].y) * invr;
|
real.x = (x[1].x + x[0].y) * invr;
|
||||||
y = detail::tdualquat<T>::value_type(0.5) * r;
|
real.y = T(0.5) * r;
|
||||||
z = (x[2].y + x[1].z) * invr;
|
real.z = (x[2].y + x[1].z) * invr;
|
||||||
w = (x[0].z - x[2].x) * invr;
|
real.w = (x[0].z - x[2].x) * invr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const detail::tdualquat<T>::value_type r = sqrt(detail::tdualquat<T>::value_type(1) + x[2].z - x[0].x - x[1].y);
|
T const r = sqrt(T(1) + x[2].z - x[0].x - x[1].y);
|
||||||
const detail::tdualquat<T>::value_type invr = detail::tdualquat<T>::value_type(0.5) / r;
|
T const invr = T(0.5) / r;
|
||||||
x = (x[0].z + x[2].x) * invr;
|
real.x = (x[0].z + x[2].x) * invr;
|
||||||
y = (x[2].y + x[1].z) * invr;
|
real.y = (x[2].y + x[1].z) * invr;
|
||||||
z = detail::tdualquat<T>::value_type(0.5) * r;
|
real.z = T(0.5) * r;
|
||||||
w = (x[1].x - x[0].y) * invr;
|
real.w = (x[1].x - x[0].y) * invr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const detail::tquat<T> dual;
|
detail::tquat<T> dual;
|
||||||
dual.x = 0.5f*( x[0].w*real.w + x[1].w*real.z - x[2].w*real.y);
|
dual.x = T(0.5) * ( x[0].w * real.w + x[1].w * real.z - x[2].w * real.y);
|
||||||
dual.y = 0.5f*(-x[0].w*real.z + x[1].w*real.w + x[2].w*real.x);
|
dual.y = T(0.5) * (-x[0].w * real.z + x[1].w * real.w + x[2].w * real.x);
|
||||||
dual.z = 0.5f*( x[0].w*real.y - x[1].w*real.x + x[2].w*real.w);
|
dual.z = T(0.5) * ( x[0].w * real.y - x[1].w * real.x + x[2].w * real.w);
|
||||||
dual.w = -0.5f*( x[0].w*real.x + x[1].w*real.y + x[2].w*real.z);
|
dual.w = -T(0.5) * ( x[0].w * real.x + x[1].w * real.y + x[2].w * real.z);
|
||||||
return detail::tdualquat<T>(real, dual);
|
return detail::tdualquat<T>(real, dual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user