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>
122 template <
typename E>
141 template <
typename T1,
typename T2,
typename T3,
typename T4>
155 std::copy(
m.data,
m.data + 4, data);
163 template <
typename E>
166 data[0] = q().getC1();
167 data[1] = q().getC2();
168 data[2] = q().getC3();
169 data[3] = q().getC4();
183 template <
typename T1,
typename T2,
typename T3,
typename T4>
184 void set(
const T1& w,
const T2& ux,
const T3& uy,
const T4& uz)
186 data[0] = std::cos(w / 2.0);
187 data[1] = std::sin(w / 2.0) * ux;
188 data[2] = std::sin(w / 2.0) * uy;
189 data[3] = std::sin(w / 2.0) * uz;
203 if (i >= 3 || i >= size || j >= 3 || j >= size)
213 return (data[0] * data[0] + data[1] * data[1] - data[2] * data[2] - data[3] * data[3]);
217 return 2 * (data[1] * data[2] - data[0] * data[3]);
221 return 2 * (data[1] * data[3] + data[0] * data[2]);
232 return 2 * (data[1] * data[2] + data[0] * data[3]);
236 return (data[0] * data[0] - data[1] * data[1] + data[2] * data[2] - data[3] * data[3]);
240 return 2 * (data[2] * data[3] - data[0] * data[1]);
251 return 2 * (data[1] * data[3] - data[0] * data[2]);
255 return 2 * (data[2] * data[3] + data[0] * data[1]);
259 return (data[0] * data[0] - data[1] * data[1] - data[2] * data[2] + data[3] * data[3]);
303 return std::numeric_limits<SizeType>::max();
312 return std::numeric_limits<SizeType>::max();
323 std::copy(
m.data,
m.data + 4, data);
337 std::swap_ranges(data, data + 4,
m.data);
338 std::swap(size,
m.size);
376 template <
typename T>
449 std::copy(
m.data,
m.data + 3, data);
480 if (i < size && i < 3)
519 return std::numeric_limits<SizeType>::max();
528 return std::numeric_limits<SizeType>::max();
539 std::copy(
m.data,
m.data + 3, data);
553 std::swap_ranges(data, data + 3,
m.data);
554 std::swap(size,
m.size);
593 template <
typename T>
666 std::copy(
m.data,
m.data + 3, data);
697 if (j == (size - 1) && i < size && i < 3)
736 return std::numeric_limits<SizeType>::max();
745 return std::numeric_limits<SizeType>::max();
756 std::copy(
m.data,
m.data + 3, data);
770 std::swap_ranges(data, data + 3,
m.data);
771 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:262
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:510
CRTP base class of all quaternion expression types.
Definition: Expression.hpp:148
N×N 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:334
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:104
void resize(SizeType n)
Resizes the matrix dimension to n (the underlying quaternion is left unchanged).
Definition: AffineTransform.hpp:356
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:184
SizeType getSize1() const
Returns the dimension N (the row count).
Definition: AffineTransform.hpp:283
friend void swap(RotationMatrix &m1, RotationMatrix &m2)
ADL-enabled free-function form of swap().
Definition: AffineTransform.hpp:347
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: AffineTransform.hpp:301
RotationMatrix(SizeType n, const QuaternionExpression< E > &q)
Constructs an N×N rotation matrix from the unit quaternion q.
Definition: AffineTransform.hpp:123
RotationMatrix & operator=(const RotationMatrix &m)
Copy-assigns the dimension and the underlying quaternion components from m.
Definition: AffineTransform.hpp:320
std::size_t SizeType
The unsigned size type.
Definition: AffineTransform.hpp:89
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:99
bool isEmpty() const
Tells whether the matrix is empty (size zero).
Definition: AffineTransform.hpp:274
RotationMatrix(const RotationMatrix &m)
Constructs a copy of the rotation matrix m.
Definition: AffineTransform.hpp:152
const T Reference
Element reference type (always a const reference — elements are computed).
Definition: AffineTransform.hpp:79
void set(const QuaternionExpression< E > &q)
Sets the rotation from the unit quaternion q.
Definition: AffineTransform.hpp:164
const T ConstReference
Constant element reference type.
Definition: AffineTransform.hpp:84
RotationMatrix(SizeType n, const T1 &w, const T2 &ux, const T3 &uy, const T4 &uz)
Constructs an N×N rotation matrix from an axis-angle representation.
Definition: AffineTransform.hpp:142
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: AffineTransform.hpp:310
Matrix< T, std::vector< T > > MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: AffineTransform.hpp:109
T ValueType
The scalar value type.
Definition: AffineTransform.hpp:74
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: AffineTransform.hpp:114
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: AffineTransform.hpp:94
SizeType getSize2() const
Returns the dimension N (the column count).
Definition: AffineTransform.hpp:292
ConstReference operator()(SizeType i, SizeType j) const
Returns the rotation matrix element at (i, j).
Definition: AffineTransform.hpp:199
N×N diagonal scaling matrix.
Definition: AffineTransform.hpp:378
void resize(SizeType n)
Resizes the matrix dimension to n (the scale factors are left unchanged).
Definition: AffineTransform.hpp:572
ScalingMatrix(const ScalingMatrix &m)
Constructs a copy of the scaling matrix m.
Definition: AffineTransform.hpp:446
Matrix< T, std::vector< T > > MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: AffineTransform.hpp:421
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: AffineTransform.hpp:526
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: AffineTransform.hpp:426
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:416
friend void swap(ScalingMatrix &m1, ScalingMatrix &m2)
ADL-enabled free-function form of swap().
Definition: AffineTransform.hpp:563
bool isEmpty() const
Tells whether the matrix is empty (size zero).
Definition: AffineTransform.hpp:490
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: AffineTransform.hpp:406
std::size_t SizeType
The unsigned size type.
Definition: AffineTransform.hpp:401
ConstReference operator()(SizeType i, SizeType j) const
Returns the scaling matrix element at (i, j).
Definition: AffineTransform.hpp:473
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:411
SizeType getSize2() const
Returns the dimension N (the column count).
Definition: AffineTransform.hpp:508
T ValueType
The scalar value type.
Definition: AffineTransform.hpp:386
SizeType getSize1() const
Returns the dimension N (the row count).
Definition: AffineTransform.hpp:499
ScalingMatrix & operator=(const ScalingMatrix &m)
Copy-assigns the dimension and the per-axis scale factors from m.
Definition: AffineTransform.hpp:536
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: AffineTransform.hpp:517
void swap(ScalingMatrix &m)
Swaps the dimension and the per-axis scale factors with m.
Definition: AffineTransform.hpp:550
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:458
ScalingMatrix(SizeType n, const ValueType &sx=ValueType(1), const ValueType &sy=ValueType(1), const ValueType &sz=ValueType(1))
Constructs an N×N scaling matrix with the supplied per-axis scale factors.
Definition: AffineTransform.hpp:435
const T ConstReference
Constant element reference type.
Definition: AffineTransform.hpp:396
const T Reference
Element reference type (always a const reference — elements are computed).
Definition: AffineTransform.hpp:391
N×N translation matrix in homogeneous coordinates.
Definition: AffineTransform.hpp:595
const MatrixReference< const SelfType > ConstClosureType
Constant closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:633
friend void swap(TranslationMatrix &m1, TranslationMatrix &m2)
ADL-enabled free-function form of swap().
Definition: AffineTransform.hpp:780
std::ptrdiff_t DifferenceType
The signed difference type.
Definition: AffineTransform.hpp:623
const T Reference
Element reference type (always a const reference — elements are computed).
Definition: AffineTransform.hpp:608
SizeType getSize1() const
Returns the dimension N (the row count).
Definition: AffineTransform.hpp:716
Vector< T, std::vector< T > > VectorTemporaryType
Concrete temporary vector type used when assembling vectors from this matrix.
Definition: AffineTransform.hpp:643
const T ConstReference
Constant element reference type.
Definition: AffineTransform.hpp:613
TranslationMatrix(const TranslationMatrix &m)
Constructs a copy of the translation matrix m.
Definition: AffineTransform.hpp:663
TranslationMatrix & operator=(const TranslationMatrix &m)
Copy-assigns the dimension and the translation components from m.
Definition: AffineTransform.hpp:753
bool isEmpty() const
Tells whether the matrix is empty (size zero).
Definition: AffineTransform.hpp:707
std::size_t SizeType
The unsigned size type.
Definition: AffineTransform.hpp:618
TranslationMatrix(SizeType n, const ValueType &tx=ValueType(), const ValueType &ty=ValueType(), const ValueType &tz=ValueType())
Constructs an N×N translation matrix with the supplied per-axis translation components.
Definition: AffineTransform.hpp:652
void set(const ValueType &tx=ValueType(), const ValueType &ty=ValueType(), const ValueType &tz=ValueType())
Sets the per-axis translation components.
Definition: AffineTransform.hpp:675
void resize(SizeType n)
Resizes the matrix dimension to n (the translation components are left unchanged).
Definition: AffineTransform.hpp:789
Matrix< T, std::vector< T > > MatrixTemporaryType
Concrete temporary matrix type used by expression template machinery.
Definition: AffineTransform.hpp:638
T ValueType
The scalar value type.
Definition: AffineTransform.hpp:603
SizeType getMaxSize1() const
Returns the maximum representable row count.
Definition: AffineTransform.hpp:734
ConstReference operator()(SizeType i, SizeType j) const
Returns the translation matrix element at (i, j).
Definition: AffineTransform.hpp:690
void swap(TranslationMatrix &m)
Swaps the dimension and the translation components with m.
Definition: AffineTransform.hpp:767
SizeType getSize2() const
Returns the dimension N (the column count).
Definition: AffineTransform.hpp:725
MatrixReference< SelfType > ClosureType
Closure type used when this matrix appears inside another expression.
Definition: AffineTransform.hpp:628
SizeType getMaxSize2() const
Returns the maximum representable column count.
Definition: AffineTransform.hpp:743
Dynamically-sized dense vector with configurable underlying storage.
Definition: Vector.hpp:480
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
Scaling matrix holding floating-point values of type float.
Definition: AffineTransform.hpp:804
RotationMatrix< float > FRotationMatrix
Rotation matrix holding floating-point values of type float.
Definition: AffineTransform.hpp:824
TranslationMatrix< long > LTranslationMatrix
Translation matrix holding integer values of type long.
Definition: AffineTransform.hpp:854
ScalingMatrix< long > LScalingMatrix
Scaling matrix holding integer values of type long.
Definition: AffineTransform.hpp:814
RotationMatrix< double > DRotationMatrix
Rotation matrix holding floating-point values of type double.
Definition: AffineTransform.hpp:829
ScalingMatrix< double > DScalingMatrix
Scaling matrix holding floating-point values of type double.
Definition: AffineTransform.hpp:809
TranslationMatrix< double > DTranslationMatrix
Translation matrix holding floating-point values of type double.
Definition: AffineTransform.hpp:849
TranslationMatrix< unsigned long > ULTranslationMatrix
Translation matrix holding unsigned integer values of type unsigned long.
Definition: AffineTransform.hpp:859
TranslationMatrix< float > FTranslationMatrix
Translation matrix holding floating-point values of type float.
Definition: AffineTransform.hpp:844
ScalingMatrix< unsigned long > ULScalingMatrix
Scaling matrix holding unsigned integer values of type unsigned long.
Definition: AffineTransform.hpp:819
RotationMatrix< unsigned long > ULRotationMatrix
Rotation matrix holding unsigned integer values of type unsigned long.
Definition: AffineTransform.hpp:839
RotationMatrix< long > LRotationMatrix
Rotation matrix holding integer values of type long.
Definition: AffineTransform.hpp:834
The namespace of the Chemical Data Processing Library.