22 #ifndef _vctMatrixRotation3Base_h
23 #define _vctMatrixRotation3Base_h
42 template <
class _matrixType,
class _quaternionType>
71 template <
class _containerType>
106 template <
class __containerType>
109 throw(std::runtime_error)
119 From(
const value_type & element00,
const value_type & element01,
const value_type & element02,
120 const value_type & element10,
const value_type & element11,
const value_type & element12,
121 const value_type & element20,
const value_type & element21,
const value_type & element22)
122 throw(std::runtime_error)
124 this->
FromRaw(element00, element01, element02,
125 element10, element11, element12,
126 element20, element21, element22);
137 template <
stride_type __stride1,
class __dataPtrType1,
144 bool vectorsAreColumns =
true)
145 throw(std::runtime_error)
147 this->
FromRaw(v1, v2, v3, vectorsAreColumns);
159 template <
class __vectorOwnerType1,
160 class __vectorOwnerType2,
161 class __vectorOwnerType3>
166 bool vectorsAreColumns =
true)
167 throw (std::runtime_error)
169 this->
FromRaw(v1, v2, v3, vectorsAreColumns);
177 throw(std::runtime_error)
180 return this->
FromRaw(axisAngleRotation);
184 template <
class __containerType>
187 throw(std::runtime_error)
190 return this->
FromRaw(quaternionRotation);
195 template <
class __containerType>
198 throw(std::runtime_error)
201 return this->
FromRaw(rodriguezRotation);
205 template <vctEulerRotation3Order::OrderType __order>
208 throw(std::runtime_error)
211 return this->
FromRaw(eulerRotation);
232 template <
class __containerType>
235 throw(std::runtime_error)
245 FromNormalized(
const value_type & element00,
const value_type & element01,
const value_type & element02,
246 const value_type & element10,
const value_type & element11,
const value_type & element12,
247 const value_type & element20,
const value_type & element21,
const value_type & element22)
249 this->
FromRaw(element00, element01, element02,
250 element10, element11, element12,
251 element20, element21, element22);
262 template <
stride_type __stride1,
class __dataPtrType1,
269 bool vectorsAreColumns =
true)
270 throw(std::runtime_error)
272 this->
FromRaw(v1, v2, v3, vectorsAreColumns);
284 template <
class __vectorOwnerType1,
285 class __vectorOwnerType2,
286 class __vectorOwnerType3>
291 bool vectorsAreColumns =
true)
293 this->
FromRaw(v1, v2, v3, vectorsAreColumns);
310 template <
class __containerType>
319 template <
class __containerType>
328 template <vctEulerRotation3Order::OrderType __order>
352 template <
class __containerType>
355 throw(std::runtime_error)
364 FromRaw(
const value_type & element00,
const value_type & element01,
const value_type & element02,
365 const value_type & element10,
const value_type & element11,
const value_type & element12,
366 const value_type & element20,
const value_type & element21,
const value_type & element22)
368 this->
Assign(element00, element01, element02,
369 element10, element11, element12,
370 element20, element21, element22);
381 template <
stride_type __stride1,
class __dataPtrType1,
388 bool vectorsAreColumns =
true)
390 if (vectorsAreColumns) {
391 this->Column(0).Assign(v1);
392 this->Column(1).Assign(v2);
393 this->Column(2).Assign(v3);
395 this->Row(0).Assign(v1);
396 this->Row(1).Assign(v2);
397 this->Row(2).Assign(v3);
409 template <
class __vectorOwnerType1,
410 class __vectorOwnerType2,
411 class __vectorOwnerType3>
416 bool vectorsAreColumns =
true)
417 throw (std::runtime_error)
422 if (vectorsAreColumns) {
423 this->Column(0).Assign(v1);
424 this->Column(1).Assign(v2);
425 this->Column(2).Assign(v3);
427 this->Row(0).Assign(v1);
428 this->Row(1).Assign(v2);
429 this->Row(2).Assign(v3);
441 template <
class __containerType>
450 template <
class __containerType>
457 template <vctEulerRotation3Order::OrderType __order>
460 vctEulerToMatrixRotation3(eulerRotation, *
this);
482 template <str
ide_type __rowStr
ide, str
ide_type __colStr
ide,
class __dataPtrType>
497 this->
From(quaternion);
505 CMN_ASSERT(otherMatrix.Pointer() != this->Pointer());
518 tmp = this->Element(0, 1); this->Element(0, 1) = this->Element(1, 0); this->Element(1, 0) = tmp;
519 tmp = this->Element(0, 2); this->Element(0, 2) = this->Element(2, 0); this->Element(2, 0) = tmp;
520 tmp = this->Element(1, 2); this->Element(1, 2) = this->Element(2, 1); this->Element(2, 1) = tmp;
529 CMN_ASSERT(otherRotation.Pointer() != this->Pointer());
530 this->TransposeOf(otherRotation);
537 template <
class _containerType>
543 const typename AxisAngleType::AngleType angle = axisAngleRotation.
Angle();
544 const typename AxisAngleType::AxisType axis = axisAngleRotation.
Axis();
546 const AngleType sinAngle = AngleType(sin(angle));
547 const AngleType cosAngle = AngleType(cos(angle));
548 const AngleType CompCosAngle = 1 - cosAngle;
551 this->Element(0, 0) = value_type(axis[0] * axis[0] * CompCosAngle + cosAngle);
552 this->Element(1, 0) = value_type(axis[0] * axis[1] * CompCosAngle + axis[2] * sinAngle);
553 this->Element(2, 0) = value_type(axis[0] * axis[2] * CompCosAngle - axis[1] * sinAngle);
556 this->Element(0, 1) = value_type(axis[1] * axis[0] * CompCosAngle - axis[2] * sinAngle);
557 this->Element(1, 1) = value_type(axis[1] * axis[1] * CompCosAngle + cosAngle);
558 this->Element(2, 1) = value_type(axis[1] * axis[2] * CompCosAngle + axis[0] * sinAngle);
561 this->Element(0, 2) = value_type(axis[2] * axis[0] * CompCosAngle + axis[1] * sinAngle);
562 this->Element(1, 2) = value_type(axis[2] * axis[1] * CompCosAngle - axis[0] * sinAngle);
563 this->Element(2, 2) = value_type(axis[2] * axis[2] * CompCosAngle + cosAngle);
569 template <
class _matrixType,
class _quaternionType>
574 typedef typename _matrixType::value_type value_type;
576 value_type xx = quaternionRotation.X() * quaternionRotation.X();
577 value_type xy = quaternionRotation.X() * quaternionRotation.Y();
578 value_type xz = quaternionRotation.X() * quaternionRotation.Z();
579 value_type xr = quaternionRotation.X() * quaternionRotation.
R();
580 value_type yy = quaternionRotation.Y() * quaternionRotation.Y();
581 value_type yz = quaternionRotation.Y() * quaternionRotation.Z();
582 value_type yr = quaternionRotation.Y() * quaternionRotation.
R();
583 value_type zz = quaternionRotation.Z() * quaternionRotation.Z();
584 value_type zr = quaternionRotation.Z() * quaternionRotation.
R();
585 matrixRotation.Assign(1 - 2 * (yy + zz), 2 * (xy - zr), 2 * (xz + yr),
586 2 * (xy + zr), 1 - 2 * (xx + zz), 2 * (yz - xr),
587 2 * (xz - yr), 2 * (yz + xr), 1 - 2 * (xx + yy));
590 #endif // _vctMatrixRotation3Base_h
A template for a fixed size matrix with fixed spacing in memory.
Definition: vctFixedSizeConstMatrixBase.h:103
Definition: vctEulerRotation3.h:153
ThisType & FromNormalized(const vctQuaternionRotation3Base< __containerType > &quaternionRotation)
Definition: vctMatrixRotation3Base.h:312
ThisType Normalized(void) const
Definition: vctEulerRotation3.h:242
_containerType ContainerType
Definition: vctMatrixRotation3Base.h:77
const AxisType & Axis(void) const
Definition: vctAxisAngleRotation3.h:314
#define CMN_ASSERT(expr)
Definition: cmnAssert.h:90
ThisType & FromRaw(const vctQuaternionRotation3Base< __containerType > &quaternionRotation)
Definition: vctMatrixRotation3Base.h:443
ThisType & FromRaw(const vctEulerRotation3< __order > &eulerRotation)
Definition: vctMatrixRotation3Base.h:459
ThisType & NormalizedOf(ThisType &otherMatrix)
Definition: vctMatrixRotation3Base.h:504
Declaration of vctMatrixRotation3ConstBase.
ThisType & From(const vctRodriguezRotation3Base< __containerType > &rodriguezRotation)
Definition: vctMatrixRotation3Base.h:197
Definition: vctMatrixRotation3Base.h:76
ThisType & From(const vctAxisAngleRotation3< value_type > &axisAngleRotation)
Definition: vctMatrixRotation3Base.h:176
ThisType & FromRaw(const vctRodriguezRotation3Base< __containerType > &rodriguezRotation)
Definition: vctMatrixRotation3Base.h:452
Declaration of vctAxisAngleRotation3.
vctMatrixRotation3Base()
Definition: vctMatrixRotation3Base.h:89
ThisType & InverseSelf(void)
Definition: vctMatrixRotation3Base.h:515
VCT_CONTAINER_TRAITS_TYPEDEFS(typename ContainerType::value_type)
void ThrowUnlessIsNormalized(void) const
Definition: vctMatrixRotation3ConstBase.h:78
ThisType & FromRaw(const vctDynamicConstVectorBase< __vectorOwnerType1, value_type > &v1, const vctDynamicConstVectorBase< __vectorOwnerType2, value_type > &v2, const vctDynamicConstVectorBase< __vectorOwnerType3, value_type > &v3, bool vectorsAreColumns=true)
Definition: vctMatrixRotation3Base.h:413
ThisType & From(const vctMatrixRotation3Base< __containerType > &other)
Definition: vctMatrixRotation3Base.h:108
ThisType Normalized(void) const
Definition: vctQuaternionRotation3Base.h:529
vctMatrixRotation3ConstBase< ContainerType > BaseType
Definition: vctMatrixRotation3Base.h:78
Definition: vctMatrixRotation3Base.h:75
ThisType & From(const vctQuaternionRotation3Base< __containerType > &quaternionRotation)
Definition: vctMatrixRotation3Base.h:186
Define a rotation based on an axis and an angle for a space of dimension 3.
Definition: vctAxisAngleRotation3.h:94
ThisType & NormalizedSelf(void)
Definition: vctQuaternionRotation3Base.h:519
size_type size(void) const
Definition: vctDynamicConstVectorBase.h:164
A template for a fixed size matrix with fixed spacings in memory.
Definition: vctFixedSizeMatrixBase.h:58
ThisType & FromNormalized(const value_type &element00, const value_type &element01, const value_type &element02, const value_type &element10, const value_type &element11, const value_type &element12, const value_type &element20, const value_type &element21, const value_type &element22)
Definition: vctMatrixRotation3Base.h:245
ThisType & From(const vctDynamicConstVectorBase< __vectorOwnerType1, value_type > &v1, const vctDynamicConstVectorBase< __vectorOwnerType2, value_type > &v2, const vctDynamicConstVectorBase< __vectorOwnerType3, value_type > &v3, bool vectorsAreColumns=true)
Definition: vctMatrixRotation3Base.h:163
ThisType & FromNormalized(const vctRodriguezRotation3Base< __containerType > &rodriguezRotation)
Definition: vctMatrixRotation3Base.h:321
Define a rotation matrix for a space of dimension 3.
Definition: vctForwardDeclarations.h:199
ThisType Normalized(void) const
Definition: vctAxisAngleRotation3.h:542
ThisType & InverseOf(const ThisType &otherRotation)
Definition: vctMatrixRotation3Base.h:528
void Assign(const OtherT &other)
Definition: cisstVectorEigenAddons.h:3
ThisType Normalized(void) const
Definition: vctRodriguezRotation3Base.h:304
ThisType & From(const value_type &element00, const value_type &element01, const value_type &element02, const value_type &element10, const value_type &element11, const value_type &element12, const value_type &element20, const value_type &element21, const value_type &element22)
Definition: vctMatrixRotation3Base.h:119
Define a rotation matrix for a space of dimension 3.
Definition: vctForwardDeclarations.h:198
Declaration of vctRodriguezRotation3Base.
vctMatrixRotation3Base< typename ContainerType::MatrixValueType > RotationValueType
Definition: vctMatrixRotation3Base.h:80
ThisType & FromRaw(const ThisType &otherRotation)
Definition: vctMatrixRotation3Base.h:468
ThisType & FromRaw(const vctMatrixRotation3Base< __containerType > &other)
Definition: vctMatrixRotation3Base.h:354
ThisType & FromNormalized(const vctFixedSizeConstVectorBase< DIMENSION, __stride1, value_type, __dataPtrType1 > &v1, const vctFixedSizeConstVectorBase< DIMENSION, __stride2, value_type, __dataPtrType2 > &v2, const vctFixedSizeConstVectorBase< DIMENSION, __stride3, value_type, __dataPtrType3 > &v3, bool vectorsAreColumns=true)
Definition: vctMatrixRotation3Base.h:266
ThisType & FromRaw(const value_type &element00, const value_type &element01, const value_type &element02, const value_type &element10, const value_type &element11, const value_type &element12, const value_type &element20, const value_type &element21, const value_type &element22)
Definition: vctMatrixRotation3Base.h:364
ThisType & FromNormalized(const vctEulerRotation3< __order > &eulerRotation)
Definition: vctMatrixRotation3Base.h:330
ThisType & FromRaw(const vctFixedSizeMatrixBase< ROWS, COLS, __rowStride, __colStride, value_type, __dataPtrType > &matrix)
Definition: vctMatrixRotation3Base.h:484
const AngleType & Angle(void) const
Definition: vctAxisAngleRotation3.h:324
const_reference R(void) const
Definition: vctQuaternionBase.h:101
ThisType & FromNormalized(const vctAxisAngleRotation3< value_type > &axisAngleRotation)
Definition: vctMatrixRotation3Base.h:300
ThisType & FromRaw(const vctFixedSizeConstVectorBase< DIMENSION, __stride1, value_type, __dataPtrType1 > &v1, const vctFixedSizeConstVectorBase< DIMENSION, __stride2, value_type, __dataPtrType2 > &v2, const vctFixedSizeConstVectorBase< DIMENSION, __stride3, value_type, __dataPtrType3 > &v3, bool vectorsAreColumns=true)
Definition: vctMatrixRotation3Base.h:385
ThisType & From(const vctEulerRotation3< __order > &eulerRotation)
Definition: vctMatrixRotation3Base.h:207
Declaration of vctEulerRotation3.
ptrdiff_t stride_type
Definition: vctContainerTraits.h:37
vctMatrixRotation3Base< ContainerType > ThisType
Definition: vctMatrixRotation3Base.h:79
Definition: vctDynamicConstVectorBase.h:77
A template for a fixed length vector with fixed spacing in memory.
Definition: vctFixedSizeConstVectorBase.h:107
const bool VCT_DO_NOT_NORMALIZE
Definition: vctForwardDeclarations.h:69
ThisType & NormalizedSelf(void)
Definition: vctMatrixRotation3Base.h:493
cmnTypeTraits< value_type > TypeTraits
Definition: vctMatrixRotation3Base.h:86
Declaration of vctQuaternionRotation3Base.
Define a rotation quaternion for a space of dimension 3.
Definition: vctForwardDeclarations.h:208
Macros to export the symbols of cisstVector (in a Dll).
void vctMatrixRotation3BaseFromRaw(vctMatrixRotation3Base< _matrixType > &matrixRotation, const vctQuaternionRotation3Base< _quaternionType > &quaternionRotation)
Definition: vctMatrixRotation3Base.h:571
A collection of useful information about the C++ basic types, represented in a generic programming wa...
Definition: cmnTypeTraits.h:155
ThisType & FromNormalized(const vctDynamicConstVectorBase< __vectorOwnerType1, value_type > &v1, const vctDynamicConstVectorBase< __vectorOwnerType2, value_type > &v2, const vctDynamicConstVectorBase< __vectorOwnerType3, value_type > &v3, bool vectorsAreColumns=true)
Definition: vctMatrixRotation3Base.h:288
Definition: vctMatrixRotation3Base.h:75
ThisType & FromNormalized(const vctMatrixRotation3Base< __containerType > &other)
Definition: vctMatrixRotation3Base.h:234
ThisType & From(const vctFixedSizeConstVectorBase< DIMENSION, __stride1, value_type, __dataPtrType1 > &v1, const vctFixedSizeConstVectorBase< DIMENSION, __stride2, value_type, __dataPtrType2 > &v2, const vctFixedSizeConstVectorBase< DIMENSION, __stride3, value_type, __dataPtrType3 > &v3, bool vectorsAreColumns=true)
Definition: vctMatrixRotation3Base.h:141
Define a rotation based on the rodriguez representation for a space of dimension 3.
Definition: vctForwardDeclarations.h:214
ThisType & FromRaw(const vctQuaternionRotation3Base< __containerType > &other)
Definition: vctQuaternionRotation3Base.h:447