20#ifndef _vctAxisAngleRotation3_h
21#define _vctAxisAngleRotation3_h
40template <
class _elementType,
class _containerType>
45template <
class _elementType,
class _containerType>
50template <
class _elementType,
class _containerType>
55#ifdef CISST_COMPILER_IS_MSVC
91template <
class _elementType>
110 cmnThrow(std::runtime_error(
"vctAxisAngleRotation3: This rotation is not normalized"));
118 template <
class _inputType>
120 if (! input.IsNormalized()) {
121 cmnThrow(std::runtime_error(
"vctAxisAngleRotation3: Input is not normalized"));
161 template <str
ide_type __str
ide,
class __dataPtrType>
163 const AngleType angle)
173 template <
class _vectorOwnerType>
182 template <
class _containerType>
187 From(quaternionRotation);
191 template <
class _containerType>
196 From(matrixRotation);
200 template <
class _containerType>
205 From(rodriguezRotation);
238 template <str
ide_type __str
ide,
class __dataPtrType>
240 const AngleType angle,
243 if (normalizeInput) {
255 template <
class _vectorOwnerType>
260 if (normalizeInput) {
268 template <
class _containerType>
272 if (normalizeInput) {
280 template <
class _containerType>
284 if (normalizeInput) {
292 template <
class _containerType>
296 if (normalizeInput) {
322 inline const AngleType &
Angle(
void)
const {
347 template <str
ide_type __str
ide,
class __dataPtrType>
349 const AngleType angle)
358 template <
class _vectorOwnerType>
372 template <
class _containerType>
377 return FromRaw(quaternionRotation);
381 template <
class _containerType>
386 return FromRaw(matrixRotation);
390 template <
class _containerType>
395 return FromRaw(rodriguezRotation);
413 template <str
ide_type __str
ide,
class __dataPtrType>
415 const AngleType angle)
423 template <
class _containerType>
429 template <
class _containerType>
435 template <
class _containerType>
454 template <str
ide_type __str
ide,
class __dataPtrType>
456 const AngleType angle)
464 template <
class _containerType>
471 template <
class _containerType>
478 template <
class _containerType>
565 return ((this->
Angle() == other.
Angle()) && (this->Axis().Equal(other.
Axis())));
569 return this->
Equal(other);
585 const AngleType angleDiff = this->
Angle() - other.
Angle();
586 const AngleType angle = (angleDiff < 0) ? -angleDiff : angleDiff;
605 const AngleType angleThis = this->
Angle();
606 const AngleType angleOther = other.
Angle();
608 if ((angleThis <= tolerance) && (angleOther <= tolerance)) {
612 if ((angleThis <= tolerance) || (angleOther <= tolerance)) {
618 const AngleType absDotProduct = dotProduct >
value_type(0.0) ? dotProduct : -dotProduct;
620 if ((absDotProduct <= (AngleType(1.0) - tolerance))
621 || (absDotProduct >= (AngleType(1.0) + tolerance))) {
625 const AngleType angleDifference = angleThis - dotProduct * angleOther;
626 AngleType angleRemain = fmod(angleDifference, 2.0 *
cmnPI);
627 if (angleRemain >
cmnPI) {
628 angleRemain -= (2.0 *
cmnPI);
629 }
else if (angleRemain < -
cmnPI) {
630 angleRemain += (2.0 *
cmnPI);
632 if ((angleRemain > -tolerance) && (angleRemain < tolerance)) {
640 std::stringstream outputStream;
642 return outputStream.str();
647 outputStream <<
"axis: "
657 void ToStreamRaw(std::ostream & outputStream,
const char delimiter =
' ',
658 bool headerOnly =
false,
const std::string & headerPrefix =
"")
const {
659 this->
Axis().ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix +
"axis-");
660 outputStream << delimiter;
662 outputStream << headerPrefix <<
"angle";
664 outputStream << this->
Angle();
671 this->
Axis().SerializeRaw(outputStream);
678 this->
Axis().DeSerializeRaw(inputStream);
686template<
class _elementType>
A collection of useful information about the C++ basic types, represented in a generic programming wa...
Definition cmnTypeTraits.h:155
static Type Tolerance(void)
Definition cmnTypeTraits.h:170
_elementType value_type
Definition mtsGenericObjectProxy.h:329
Define a rotation based on an axis and an angle for a space of dimension 3.
Definition vctAxisAngleRotation3.h:93
ThisType & FromRaw(const vctFixedSizeConstVectorBase< DIMENSION, __stride, value_type, __dataPtrType > &axis, const AngleType angle)
Definition vctAxisAngleRotation3.h:455
vctAxisAngleRotation3(const vctFixedSizeConstVectorBase< DIMENSION, __stride, value_type, __dataPtrType > &axis, const AngleType angle, bool normalizeInput)
Definition vctAxisAngleRotation3.h:239
void DeSerializeRaw(std::istream &inputStream)
Definition vctAxisAngleRotation3.h:676
vctAxisAngleRotation3(const vctRodriguezRotation3Base< _containerType > &rodriguezRotation, bool normalizeInput)
Definition vctAxisAngleRotation3.h:293
ThisType & NormalizedSelf(void)
Definition vctAxisAngleRotation3.h:516
ThisType & FromRaw(const vctQuaternionRotation3Base< _containerType > &quaternionRotation)
Definition vctAxisAngleRotation3.h:465
void ThrowUnlessIsNormalized(const _inputType &input) const CISST_THROW(std
Definition vctAxisAngleRotation3.h:119
vctAxisAngleRotation3()
Definition vctAxisAngleRotation3.h:128
ThisType Inverse(void) const
Definition vctAxisAngleRotation3.h:507
vctFixedSizeVector< value_type, DIMENSION > AxisType
Definition vctAxisAngleRotation3.h:99
ThisType & FromNormalized(const vctFixedSizeConstVectorBase< DIMENSION, __stride, value_type, __dataPtrType > &axis, const AngleType angle)
Definition vctAxisAngleRotation3.h:414
vctAxisAngleRotation3(const vctRodriguezRotation3Base< _containerType > &rodriguezRotation) CISST_THROW(std
Definition vctAxisAngleRotation3.h:202
ThisType & From(const vctDynamicConstVectorBase< _vectorOwnerType, value_type > &axis, AngleType angle) CISST_THROW(std
Definition vctAxisAngleRotation3.h:359
AngleType & Angle(void)
Definition vctAxisAngleRotation3.h:327
vctAxisAngleRotation3(const vctQuaternionRotation3Base< _containerType > &quaternionRotation, bool normalizeInput)
Definition vctAxisAngleRotation3.h:269
ThisType & From(const vctRodriguezRotation3Base< _containerType > &rodriguezRotation) CISST_THROW(std
Definition vctAxisAngleRotation3.h:391
void ThrowUnlessIsNormalized(void) const CISST_THROW(std
Definition vctAxisAngleRotation3.h:108
void ToStream(std::ostream &outputStream) const
Definition vctAxisAngleRotation3.h:646
bool IsNormalized(value_type tolerance=TypeTraits::Tolerance()) const
Definition vctAxisAngleRotation3.h:552
bool Equal(const ThisType &other) const
Definition vctAxisAngleRotation3.h:564
bool AlmostEqual(const ThisType &other, value_type tolerance=TypeTraits::Tolerance()) const
Definition vctAxisAngleRotation3.h:583
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
std::string ToString(void) const
Definition vctAxisAngleRotation3.h:639
ThisType & FromRaw(const vctMatrixRotation3Base< _containerType > &matrixRotation)
Definition vctAxisAngleRotation3.h:472
vctAxisAngleRotation3(const vctMatrixRotation3Base< _containerType > &matrixRotation) CISST_THROW(std
Definition vctAxisAngleRotation3.h:193
cmnTypeTraits< value_type > TypeTraits
Definition vctAxisAngleRotation3.h:100
ThisType & From(const vctFixedSizeConstVectorBase< DIMENSION, __stride, value_type, __dataPtrType > &axis, const AngleType angle) CISST_THROW(std
Definition vctAxisAngleRotation3.h:348
bool AlmostEquivalent(const ThisType &other, value_type tolerance=TypeTraits::Tolerance()) const
Definition vctAxisAngleRotation3.h:603
static CISST_EXPORT const ThisType & Identity()
vctAxisAngleRotation3(const vctQuaternionRotation3Base< _containerType > &quaternionRotation) CISST_THROW(std
Definition vctAxisAngleRotation3.h:184
ThisType & FromRaw(const vctRodriguezRotation3Base< _containerType > &rodriguezRotation)
Definition vctAxisAngleRotation3.h:479
const AxisType & Axis(void) const
Definition vctAxisAngleRotation3.h:312
vctAxisAngleRotation3(const vctMatrixRotation3Base< _containerType > &matrixRotation, bool normalizeInput)
Definition vctAxisAngleRotation3.h:281
ThisType & From(const vctMatrixRotation3Base< _containerType > &matrixRotation) CISST_THROW(std
Definition vctAxisAngleRotation3.h:382
AngleType AngleMember
Definition vctAxisAngleRotation3.h:104
ThisType Normalized(void) const
Definition vctAxisAngleRotation3.h:540
const AngleType & Angle(void) const
Definition vctAxisAngleRotation3.h:322
vctAxisAngleRotation3(const vctDynamicConstVectorBase< _vectorOwnerType, value_type > &axis, AngleType angle) CISST_THROW(std
Definition vctAxisAngleRotation3.h:174
vctAxisAngleRotation3(const vctDynamicConstVectorBase< _vectorOwnerType, value_type > &axis, AngleType angle, bool normalizeInput)
Definition vctAxisAngleRotation3.h:256
ThisType & InverseSelf(void)
Definition vctAxisAngleRotation3.h:491
vctAxisAngleRotation3(const vctFixedSizeConstVectorBase< DIMENSION, __stride, value_type, __dataPtrType > &axis, const AngleType angle) CISST_THROW(std
Definition vctAxisAngleRotation3.h:162
ThisType & FromNormalized(const vctMatrixRotation3Base< _containerType > &matrixRotation)
Definition vctAxisAngleRotation3.h:430
bool operator==(const ThisType &other) const
Definition vctAxisAngleRotation3.h:568
ThisType & FromNormalized(const vctRodriguezRotation3Base< _containerType > &rodriguezRotation)
Definition vctAxisAngleRotation3.h:436
AxisType & Axis(void)
Definition vctAxisAngleRotation3.h:317
ThisType & NormalizedOf(const ThisType &otherRotation)
Definition vctAxisAngleRotation3.h:530
ThisType & InverseOf(const ThisType &otherRotation)
Definition vctAxisAngleRotation3.h:498
void SerializeRaw(std::ostream &outputStream) const
Definition vctAxisAngleRotation3.h:669
ThisType & FromNormalized(const vctQuaternionRotation3Base< _containerType > &quaternionRotation)
Definition vctAxisAngleRotation3.h:424
@ DIMENSION
Definition vctAxisAngleRotation3.h:97
AxisType AxisMember
Definition vctAxisAngleRotation3.h:103
ThisType & From(const vctQuaternionRotation3Base< _containerType > &quaternionRotation) CISST_THROW(std
Definition vctAxisAngleRotation3.h:373
vctAxisAngleRotation3< value_type > ThisType
Definition vctAxisAngleRotation3.h:98
ThisType & Assign(const ThisType &other)
Definition vctAxisAngleRotation3.h:135
void ToStreamRaw(std::ostream &outputStream, const char delimiter=' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition vctAxisAngleRotation3.h:657
Definition vctForwardDeclarations.h:119
A template for a fixed length vector with fixed spacing in memory.
Definition vctFixedSizeConstVectorBase.h:108
bool IsNormalized(_elementType tolerance=cmnTypeTraits< _elementType >::Tolerance()) const
Definition vctFixedSizeConstVectorBase.h:461
Implementation of a fixed-size matrix using template metaprogramming.
Definition vctFixedSizeMatrix.h:54
ThisType & Assign(const vctFixedSizeConstVectorBase< _size, __stride, __elementType, __dataPtrType > &other)
Definition vctFixedSizeVectorBase.h:274
ThisType & NormalizedSelf(void) CISST_THROW(std
Definition vctFixedSizeVectorBase.h:1363
Implementation of a fixed-size vector using template metaprogramming.
Definition vctFixedSizeVector.h:54
Define a rotation matrix for a space of dimension 3.
Definition vctMatrixRotation3Base.h:71
RotationValueType Normalized(void) const
Definition vctMatrixRotation3.h:394
Define a rotation quaternion for a space of dimension 3.
Definition vctQuaternionRotation3Base.h:64
ThisType Normalized(void) const
Definition vctQuaternionRotation3Base.h:532
Define a rotation based on the rodriguez representation for a space of dimension 3.
Definition vctRodriguezRotation3Base.h:68
ThisType Normalized(void) const
Definition vctRodriguezRotation3Base.h:302
Declaration of various constants.
const double cmnPI
Definition cmnConstants.h:38
void cmnDeSerializeRaw(std::istream &inputStream, _elementType &data) CISST_THROW(std
Definition cmnDeSerializer.h:82
#define CISST_EXPORT
Definition cmnExportMacros.h:50
#define CISST_THROW(exceptionParameter)
Somewhat portable compilation warning message. This works with very recent versions of gcc (4....
Definition cmnPortability.h:559
void cmnSerializeRaw(std::ostream &outputStream, const _elementType &data) CISST_THROW(std
Definition cmnSerializer.h:76
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
void vctAxisAngleRotation3FromRaw(vctAxisAngleRotation3< _elementType > &axisAngleRotation, const vctQuaternionRotation3Base< _containerType > &quaternionRotation)
std::ostream & operator<<(std::ostream &output, const vctAxisAngleRotation3< _elementType > &axisAngle)
Definition vctAxisAngleRotation3.h:687
value_type DotProduct(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition vctDynamicConstVectorBase.h:633
Declaration of vctDynamicVector.
Macros to export the symbols of cisstVector (in a Dll).
Declaration of vctFixedSizeVector.
Declaration of vctMatrixRotation3Base.
Declaration of vctQuaternionRotation3Base.
Declaration of vctRodriguezRotation3Base.