27 #ifndef CDPL_MATH_QUATERNION_HPP
28 #define CDPL_MATH_QUATERNION_HPP
32 #include <type_traits>
55 typedef typename std::conditional<std::is_const<Q>::value,
56 typename Q::ConstReference,
117 data.operator=(
r.data);
121 template <
typename E>
128 template <
typename T>
136 template <
typename E>
143 template <
typename T>
151 template <
typename E>
158 template <
typename T>
166 template <
typename E>
173 template <
typename T>
181 template <
typename E>
188 template <
typename T>
196 template <
typename E>
203 template <
typename E>
210 template <
typename E>
230 data.set(c1, c2, c3, c4);
237 template <
typename T>
267 std::copy(q.data, q.data + 4, data);
270 template <
typename E>
273 quaternionAssignQuaternion<ScalarAssignment>(*
this, e);
338 std::copy(q.data, q.data + 4, data);
343 template <
typename C>
349 template <
typename E>
357 template <
typename T1>
358 typename std::enable_if<IsScalar<T1>::value,
Quaternion>::type&
369 template <
typename T1>
370 typename std::enable_if<IsScalar<T1>::value,
Quaternion>::type&
377 template <
typename C>
383 template <
typename E>
391 template <
typename T1>
392 typename std::enable_if<IsScalar<T1>::value,
Quaternion>::type&
399 template <
typename C>
405 template <
typename E>
413 template <
typename T1>
414 typename std::enable_if<IsScalar<T1>::value,
Quaternion>::type&
417 quaternionAssignScalar<ScalarMultiplicationAssignment>(*
this, t);
421 template <
typename E>
429 template <
typename T1>
430 typename std::enable_if<IsScalar<T1>::value,
Quaternion>::type&
433 quaternionAssignScalar<ScalarDivisionAssignment>(*
this, t);
437 template <
typename E>
445 template <
typename E>
448 quaternionAssignQuaternion<ScalarAssignment>(*
this, e);
452 template <
typename E>
455 quaternionAssignQuaternion<ScalarAdditionAssignment>(*
this, e);
459 template <
typename E>
462 quaternionAssignQuaternion<ScalarSubtractionAssignment>(*
this, e);
469 std::swap_ranges(data, data + 4, q.data);
481 template <
typename T>
501 template <
typename T1>
537 template <
typename T1>
544 template <
typename T1>
545 typename std::enable_if<IsScalar<T1>::value,
RealQuaternion>::type&
552 template <
typename T1>
559 template <
typename T1>
560 typename std::enable_if<IsScalar<T1>::value,
RealQuaternion>::type&
567 template <
typename T1>
574 template <
typename T1>
575 typename std::enable_if<IsScalar<T1>::value,
RealQuaternion>::type&
582 template <
typename T1>
589 template <
typename T1>
590 typename std::enable_if<IsScalar<T1>::value,
RealQuaternion>::type&
597 template <
typename T1>
604 template <
typename T1>
605 typename std::enable_if<IsScalar<T1>::value,
RealQuaternion>::type&
612 template <
typename T1>
619 template <
typename T1>
626 template <
typename T1>
636 std::swap(value, q.value);
649 template <
typename T>
652 template <
typename Q>
656 template <
typename Q>
660 template <
typename T>
667 template <
typename T1,
typename T2>
668 Quaternion<typename CommonType<T1, T2>::Type>
669 quat(
const T1& t1,
const T2& t2)
673 return QuaternionType(t1, t2);
676 template <
typename T1,
typename T2,
typename T3>
677 Quaternion<typename CommonType<typename CommonType<T1, T2>::Type, T3>::Type>
678 quat(
const T1& t1,
const T2& t2,
const T3& t3)
682 return QuaternionType(t1, t2, t3);
685 template <
typename T1,
typename T2,
typename T3,
typename T4>
686 Quaternion<typename CommonType<typename CommonType<typename CommonType<T1, T2>::Type, T3>::Type, T4>::Type>
687 quat(
const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4)
691 return QuaternionType(t1, t2, t3, t4);
Definition of various functors.
Implementation of quaternion assignment routines.
Definition of various quaternion expression types and operations.
Definition of type traits.
Definition: Expression.hpp:186
Definition: Expression.hpp:98
Definition: Quaternion.hpp:48
QuaternionReference & operator+=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:137
Reference getC3()
Definition: Quaternion.hpp:75
void set(const ValueType &c1=ValueType(), const ValueType &c2=ValueType(), const ValueType &c3=ValueType(), const ValueType &c4=ValueType())
Definition: Quaternion.hpp:227
QuaternionReference(QuaternionType &q)
Definition: Quaternion.hpp:62
ConstReference getC4() const
Definition: Quaternion.hpp:100
ConstReference getC2() const
Definition: Quaternion.hpp:90
QuaternionReference & operator=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:122
std::enable_if< IsScalar< T >::value, QuaternionReference >::type & operator-=(const T &t)
Definition: Quaternion.hpp:160
std::enable_if< IsScalar< T >::value, QuaternionReference >::type & operator/=(const T &t)
Definition: Quaternion.hpp:190
ConstReference getC1() const
Definition: Quaternion.hpp:85
SelfType ClosureType
Definition: Quaternion.hpp:59
QuaternionReference & operator-=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:152
const SelfType ConstClosureType
Definition: Quaternion.hpp:60
Reference getC1()
Definition: Quaternion.hpp:65
void swap(QuaternionReference &r)
Definition: Quaternion.hpp:217
Q::ValueType ValueType
Definition: Quaternion.hpp:54
QuaternionType & getData()
Definition: Quaternion.hpp:110
Reference getC4()
Definition: Quaternion.hpp:80
Q::ConstReference ConstReference
Definition: Quaternion.hpp:58
std::enable_if< IsScalar< T >::value, QuaternionReference >::type & operator+=(const T &t)
Definition: Quaternion.hpp:145
const QuaternionType & getData() const
Definition: Quaternion.hpp:105
QuaternionReference & minusAssign(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:211
std::enable_if< IsScalar< T >::value, QuaternionReference >::type & operator=(const T &t)
Definition: Quaternion.hpp:130
QuaternionReference & operator/=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:182
QuaternionReference & operator=(const QuaternionReference &r)
Definition: Quaternion.hpp:115
QuaternionReference & operator*=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:167
std::conditional< std::is_const< Q >::value, typename Q::ConstReference, typename Q::Reference >::type Reference
Definition: Quaternion.hpp:57
Reference getC2()
Definition: Quaternion.hpp:70
QuaternionReference & assign(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:197
Q QuaternionType
Definition: Quaternion.hpp:53
QuaternionReference & plusAssign(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:204
ConstReference getC3() const
Definition: Quaternion.hpp:95
friend void swap(QuaternionReference &r1, QuaternionReference &r2)
Definition: Quaternion.hpp:222
std::enable_if< IsScalar< T >::value, QuaternionReference >::type & operator*=(const T &t)
Definition: Quaternion.hpp:175
Definition: Quaternion.hpp:239
Reference getC3()
Definition: Quaternion.hpp:296
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator+=(const T1 &t)
Definition: Quaternion.hpp:371
Quaternion & plusAssign(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:453
ValueType ArrayType[4]
Definition: Quaternion.hpp:247
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator=(const T1 &t)
Definition: Quaternion.hpp:359
Reference getC1()
Definition: Quaternion.hpp:286
Quaternion & operator=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:350
T * Pointer
Definition: Quaternion.hpp:248
Quaternion & operator=(const QuaternionContainer< C > &c)
Definition: Quaternion.hpp:344
const T & ConstReference
Definition: Quaternion.hpp:246
Quaternion(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:271
Quaternion & operator-=(const QuaternionContainer< C > &c)
Definition: Quaternion.hpp:400
Pointer getData()
Definition: Quaternion.hpp:276
ConstReference getC1() const
Definition: Quaternion.hpp:306
Quaternion & minusAssign(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:460
Quaternion & operator+=(const QuaternionContainer< C > &c)
Definition: Quaternion.hpp:378
Quaternion & operator=(const Quaternion &q)
Definition: Quaternion.hpp:335
ConstReference getC4() const
Definition: Quaternion.hpp:321
Quaternion & operator*=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:422
SelfType QuaternionTemporaryType
Definition: Quaternion.hpp:252
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator-=(const T1 &t)
Definition: Quaternion.hpp:393
ConstReference getC3() const
Definition: Quaternion.hpp:316
friend void swap(Quaternion &q1, Quaternion &q2)
Definition: Quaternion.hpp:472
void swap(Quaternion &q)
Definition: Quaternion.hpp:466
Quaternion(const ValueType &c1, const ValueType &c2=ValueType(), const ValueType &c3=ValueType(), const ValueType &c4=ValueType())
Definition: Quaternion.hpp:256
const T * ConstPointer
Definition: Quaternion.hpp:249
QuaternionReference< SelfType > ClosureType
Definition: Quaternion.hpp:250
Quaternion(const Quaternion &q)
Definition: Quaternion.hpp:265
Quaternion & operator-=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:406
Quaternion()
Definition: Quaternion.hpp:254
Quaternion & operator+=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:384
T ValueType
Definition: Quaternion.hpp:244
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator/=(const T1 &t)
Definition: Quaternion.hpp:431
Reference getC4()
Definition: Quaternion.hpp:301
Reference getC2()
Definition: Quaternion.hpp:291
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator*=(const T1 &t)
Definition: Quaternion.hpp:415
Quaternion & assign(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:446
T & Reference
Definition: Quaternion.hpp:245
Quaternion & operator/=(const QuaternionExpression< E > &e)
Definition: Quaternion.hpp:438
void set(const ValueType &c1=ValueType(), const ValueType &c2=ValueType(), const ValueType &c3=ValueType(), const ValueType &c4=ValueType())
Definition: Quaternion.hpp:326
ConstPointer getData() const
Definition: Quaternion.hpp:281
const QuaternionReference< const SelfType > ConstClosureType
Definition: Quaternion.hpp:251
ConstReference getC2() const
Definition: Quaternion.hpp:311
Definition: Quaternion.hpp:483
RealQuaternion & plusAssign(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:620
ConstReference getC4() const
Definition: Quaternion.hpp:521
RealQuaternion(const ValueType &r)
Definition: Quaternion.hpp:498
std::enable_if< IsScalar< T1 >::value, RealQuaternion >::type & operator/=(const T1 &t)
Definition: Quaternion.hpp:606
RealQuaternion()
Definition: Quaternion.hpp:495
T ValueType
Definition: Quaternion.hpp:488
std::enable_if< IsScalar< T1 >::value, RealQuaternion >::type & operator-=(const T1 &t)
Definition: Quaternion.hpp:576
RealQuaternion & operator-=(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:568
std::enable_if< IsScalar< T1 >::value, RealQuaternion >::type & operator*=(const T1 &t)
Definition: Quaternion.hpp:591
RealQuaternion & operator=(const RealQuaternion &q)
Definition: Quaternion.hpp:531
ConstReference getC1() const
Definition: Quaternion.hpp:506
RealQuaternion & operator/=(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:598
RealQuaternion & operator=(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:538
RealQuaternion & assign(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:613
std::enable_if< IsScalar< T1 >::value, RealQuaternion >::type & operator+=(const T1 &t)
Definition: Quaternion.hpp:561
const T & ConstReference
Definition: Quaternion.hpp:490
RealQuaternion(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:502
const T & Reference
Definition: Quaternion.hpp:489
QuaternionReference< SelfType > ClosureType
Definition: Quaternion.hpp:491
ConstReference getC3() const
Definition: Quaternion.hpp:516
Quaternion< T > QuaternionTemporaryType
Definition: Quaternion.hpp:493
ConstReference getC2() const
Definition: Quaternion.hpp:511
RealQuaternion & operator*=(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:583
RealQuaternion & minusAssign(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:627
friend void swap(RealQuaternion &q1, RealQuaternion &q2)
Definition: Quaternion.hpp:639
void swap(RealQuaternion &q)
Definition: Quaternion.hpp:633
RealQuaternion & operator+=(const RealQuaternion< T1 > &q)
Definition: Quaternion.hpp:553
const QuaternionReference< const SelfType > ConstClosureType
Definition: Quaternion.hpp:492
std::enable_if< IsScalar< T1 >::value, RealQuaternion >::type & operator=(const T1 &t)
Definition: Quaternion.hpp:546
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int Q
A generic type that covers any element except hydrogen and carbon.
Definition: AtomType.hpp:647
constexpr unsigned int r
Specifies that the stereocenter has r configuration.
Definition: CIPDescriptor.hpp:76
RealQuaternion< float > FRealQuaternion
Definition: Quaternion.hpp:699
Quaternion< unsigned long > ULQuaternion
Definition: Quaternion.hpp:697
Quaternion< double > DQuaternion
Definition: Quaternion.hpp:695
RealQuaternion< double > DRealQuaternion
Definition: Quaternion.hpp:700
Quaternion< float > FQuaternion
Definition: Quaternion.hpp:694
RealQuaternion< unsigned long > ULRealQuaternion
Definition: Quaternion.hpp:702
std::enable_if< IsScalar< T >::value, RealQuaternion< T > >::type quat(const T &t)
Definition: Quaternion.hpp:662
RealQuaternion< long > LRealQuaternion
Definition: Quaternion.hpp:701
Quaternion< long > LQuaternion
Definition: Quaternion.hpp:696
The namespace of the Chemical Data Processing Library.
Definition: TypeTraits.hpp:193