27 #ifndef CDPL_MATH_AFFINETRANSFORM_HPP
28 #define CDPL_MATH_AFFINETRANSFORM_HPP
49 class MatrixReference;
50 template <
typename T,
typename A>
52 template <
typename T,
typename A>
115 template <
typename T1,
typename T2,
typename T3,
typename T4>
129 std::copy(
m.data,
m.data + 4, data);
137 template <
typename E>
140 data[0] = q().getC1();
141 data[1] = q().getC2();
142 data[2] = q().getC3();
143 data[3] = q().getC4();
157 template <
typename T1,
typename T2,
typename T3,
typename T4>
158 void set(
const T1& w,
const T2& ux,
const T3& uy,
const T4& uz)
160 data[0] = std::cos(w / 2.0);
161 data[1] = std::sin(w / 2.0) * ux;
162 data[2] = std::sin(w / 2.0) * uy;
163 data[3] = std::sin(w / 2.0) * uz;
177 if (i >= 3 || i >= size || j >= 3 || j >= size)
187 return (data[0] * data[0] + data[1] * data[1] - data[2] * data[2] - data[3] * data[3]);
191 return 2 * (data[1] * data[2] - data[0] * data[3]);
195 return 2 * (data[1] * data[3] + data[0] * data[2]);
206 return 2 * (data[1] * data[2] + data[0] * data[3]);
210 return (data[0] * data[0] - data[1] * data[1] + data[2] * data[2] - data[3] * data[3]);
214 return 2 * (data[2] * data[3] - data[0] * data[1]);
225 return 2 * (data[1] * data[3] - data[0] * data[2]);
229 return 2 * (data[2] * data[3] + data[0] * data[1]);
233 return (data[0] * data[0] - data[1] * data[1] - data[2] * data[2] + data[3] * data[3]);
277 return std::numeric_limits<SizeType>::max();
286 return std::numeric_limits<SizeType>::max();
297 std::copy(
m.data,
m.data + 4, data);
311 std::swap_ranges(data, data + 4,
m.data);
312 std::swap(size,
m.size);
350 template <
typename T>
397 std::copy(
m.data,
m.data + 3, data);
428 if (i < size && i < 3)
467 return std::numeric_limits<SizeType>::max();
476 return std::numeric_limits<SizeType>::max();
487 std::copy(
m.data,
m.data + 3, data);
501 std::swap_ranges(data, data + 3,
m.data);
502 std::swap(size,
m.size);
541 template <
typename T>
588 std::copy(
m.data,
m.data + 3, data);
619 if (j == (size - 1) && i < size && i < 3)
658 return std::numeric_limits<SizeType>::max();
667 return std::numeric_limits<SizeType>::max();
678 std::copy(
m.data,
m.data + 3, data);
692 std::swap_ranges(data, data + 3,
m.data);
693 std::swap(size,
m.size);
Definition of exception classes.
Definition of various preprocessor macros for error checking.
#define CDPL_MATH_CHECK(expr, msg, e)
Throws the exception e with message msg when the boolean expression expr evaluates to false.
Definition: Check.hpp:47
Definition of basic expression types.
Thrown to indicate that an index is out of range.
Definition: Base/Exceptions.hpp:152
Refinement of Math::MatrixExpression marking the derived type as a concrete (writable) matrix contain...
Definition: Expression.hpp:250
Lightweight matrix expression that proxies a reference to an underlying matrix container.
Definition: Matrix.hpp:64
Dynamically-sized dense row-major matrix with configurable underlying storage.
Definition: Matrix.hpp:455
CRTP base class for all quaternion expression types.
Definition: Expression.hpp:142
rotation matrix backed by a unit quaternion (or an axis-angle representation).
Definition: AffineTransform.hpp:66
void swap(RotationMatrix &m)
Swaps the dimension and the underlying quaternion components with m.
Definition: AffineTransform.hpp:308
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:84
void resize(SizeType n)
Resizes the matrix dimension to n (the underlying quaternion is left unchanged).
Definition: AffineTransform.hpp:330
void set(const T1 &w, const T2 &ux, const T3 &uy, const T4 &uz)
Sets the rotation from an axis-angle representation.
Definition: AffineTransform.hpp:158
SizeType getSize1() const
Returns the dimension N (the row count).
Definition: AffineTransform.hpp:257
friend void swap(RotationMatrix &m1, RotationMatrix &m2)
ADL-enabled free-function form of swap().
Definition: AffineTransform.hpp:321
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: AffineTransform.hpp:275
RotationMatrix(SizeType n, const QuaternionExpression< E > &q)
Constructs an rotation matrix from the unit quaternion q.
Definition: AffineTransform.hpp:97
RotationMatrix & operator=(const RotationMatrix &m)
Copy-assigns the dimension and the underlying quaternion components from m.
Definition: AffineTransform.hpp:294
std::size_t SizeType
The unsigned size type.
Definition: AffineTransform.hpp:78
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:82
bool isEmpty() const
Tells whether the matrix is empty (size zero).
Definition: AffineTransform.hpp:248
RotationMatrix(const RotationMatrix &m)
Constructs a copy of the rotation matrix m.
Definition: AffineTransform.hpp:126
const T Reference
Reference type (always a const reference — elements are computed).
Definition: AffineTransform.hpp:74
void set(const QuaternionExpression< E > &q)
Sets the rotation from the unit quaternion q.
Definition: AffineTransform.hpp:138
const T ConstReference
Constant reference type to an element.
Definition: AffineTransform.hpp:76
RotationMatrix(SizeType n, const T1 &w, const T2 &ux, const T3 &uy, const T4 &uz)
Constructs an rotation matrix from an axis-angle representation.
Definition: AffineTransform.hpp:116
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: AffineTransform.hpp:284
Matrix< T, std::vector< T > > MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: AffineTransform.hpp:86
T ValueType
The scalar value type.
Definition: AffineTransform.hpp:72
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: AffineTransform.hpp:88
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: AffineTransform.hpp:80
SizeType getSize2() const
Returns the dimension N (the column count).
Definition: AffineTransform.hpp:266
ConstReference operator()(SizeType i, SizeType j) const
Returns the rotation-matrix entry at (i, j).
Definition: AffineTransform.hpp:173
diagonal scaling matrix.
Definition: AffineTransform.hpp:352
void resize(SizeType n)
Resizes the matrix dimension to n (the scale factors are left unchanged).
Definition: AffineTransform.hpp:520
ScalingMatrix(const ScalingMatrix &m)
Constructs a copy of the scaling matrix m.
Definition: AffineTransform.hpp:394
Matrix< T, std::vector< T > > MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: AffineTransform.hpp:372
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: AffineTransform.hpp:474
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: AffineTransform.hpp:374
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:370
friend void swap(ScalingMatrix &m1, ScalingMatrix &m2)
ADL-enabled free-function form of swap().
Definition: AffineTransform.hpp:511
bool isEmpty() const
Tells whether the matrix is empty (size zero).
Definition: AffineTransform.hpp:438
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: AffineTransform.hpp:366
std::size_t SizeType
The unsigned size type.
Definition: AffineTransform.hpp:364
ConstReference operator()(SizeType i, SizeType j) const
Returns the scaling-matrix entry at (i, j).
Definition: AffineTransform.hpp:421
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:368
SizeType getSize2() const
Returns the dimension N (the column count).
Definition: AffineTransform.hpp:456
T ValueType
The scalar value type.
Definition: AffineTransform.hpp:358
SizeType getSize1() const
Returns the dimension N (the row count).
Definition: AffineTransform.hpp:447
ScalingMatrix & operator=(const ScalingMatrix &m)
Copy-assigns the dimension and the per-axis scale factors from m.
Definition: AffineTransform.hpp:484
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: AffineTransform.hpp:465
void swap(ScalingMatrix &m)
Swaps the dimension and the per-axis scale factors with m.
Definition: AffineTransform.hpp:498
void set(const ValueType &sx=ValueType(1), const ValueType &sy=ValueType(1), const ValueType &sz=ValueType(1))
Sets the per-axis scale factors.
Definition: AffineTransform.hpp:406
ScalingMatrix(SizeType n, const ValueType &sx=ValueType(1), const ValueType &sy=ValueType(1), const ValueType &sz=ValueType(1))
Constructs an scaling matrix with the supplied per-axis scale factors.
Definition: AffineTransform.hpp:383
const T ConstReference
Constant reference type to an element.
Definition: AffineTransform.hpp:362
const T Reference
Reference type (always a const reference — elements are computed).
Definition: AffineTransform.hpp:360
translation matrix in homogeneous coordinates.
Definition: AffineTransform.hpp:543
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:561
friend void swap(TranslationMatrix &m1, TranslationMatrix &m2)
ADL-enabled free-function form of swap().
Definition: AffineTransform.hpp:702
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: AffineTransform.hpp:557
const T Reference
Reference type (always a const reference — elements are computed).
Definition: AffineTransform.hpp:551
SizeType getSize1() const
Returns the dimension N (the row count).
Definition: AffineTransform.hpp:638
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: AffineTransform.hpp:565
const T ConstReference
Constant reference type to an element.
Definition: AffineTransform.hpp:553
TranslationMatrix(const TranslationMatrix &m)
Constructs a copy of the translation matrix m.
Definition: AffineTransform.hpp:585
TranslationMatrix & operator=(const TranslationMatrix &m)
Copy-assigns the dimension and the translation components from m.
Definition: AffineTransform.hpp:675
bool isEmpty() const
Tells whether the matrix is empty (size zero).
Definition: AffineTransform.hpp:629
std::size_t SizeType
The unsigned size type.
Definition: AffineTransform.hpp:555
TranslationMatrix(SizeType n, const ValueType &tx=ValueType(), const ValueType &ty=ValueType(), const ValueType &tz=ValueType())
Constructs an translation matrix with the supplied per-axis translation components.
Definition: AffineTransform.hpp:574
void set(const ValueType &tx=ValueType(), const ValueType &ty=ValueType(), const ValueType &tz=ValueType())
Sets the per-axis translation components.
Definition: AffineTransform.hpp:597
void resize(SizeType n)
Resizes the matrix dimension to n (the translation components are left unchanged).
Definition: AffineTransform.hpp:711
Matrix< T, std::vector< T > > MatrixTemporaryType
Concrete temporary matrix type used by expression-template machinery.
Definition: AffineTransform.hpp:563
T ValueType
The scalar value type.
Definition: AffineTransform.hpp:549
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: AffineTransform.hpp:656
ConstReference operator()(SizeType i, SizeType j) const
Returns the translation-matrix entry at (i, j).
Definition: AffineTransform.hpp:612
void swap(TranslationMatrix &m)
Swaps the dimension and the translation components with m.
Definition: AffineTransform.hpp:689
SizeType getSize2() const
Returns the dimension N (the column count).
Definition: AffineTransform.hpp:647
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:559
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: AffineTransform.hpp:665
Dynamically-sized dense vector with configurable underlying storage.
Definition: Vector.hpp:430
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int m
Specifies that the stereocenter has m configuration.
Definition: CIPDescriptor.hpp:116
ScalingMatrix< float > FScalingMatrix
Definition: AffineTransform.hpp:723
RotationMatrix< float > FRotationMatrix
Definition: AffineTransform.hpp:728
TranslationMatrix< long > LTranslationMatrix
Definition: AffineTransform.hpp:735
ScalingMatrix< long > LScalingMatrix
Definition: AffineTransform.hpp:725
RotationMatrix< double > DRotationMatrix
Definition: AffineTransform.hpp:729
ScalingMatrix< double > DScalingMatrix
Definition: AffineTransform.hpp:724
TranslationMatrix< double > DTranslationMatrix
Definition: AffineTransform.hpp:734
TranslationMatrix< unsigned long > ULTranslationMatrix
Definition: AffineTransform.hpp:736
TranslationMatrix< float > FTranslationMatrix
Definition: AffineTransform.hpp:733
ScalingMatrix< unsigned long > ULScalingMatrix
Definition: AffineTransform.hpp:726
RotationMatrix< unsigned long > ULRotationMatrix
Definition: AffineTransform.hpp:731
RotationMatrix< long > LRotationMatrix
Definition: AffineTransform.hpp:730
The namespace of the Chemical Data Processing Library.