cisst-saw
Loading...
Searching...
No Matches
vctFrame4x4Base.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Anton Deguet
6 Created on: 2007-09-13
7
8 (C) Copyright 2007-2018 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19#pragma once
20#ifndef _vctFrame4x4Base_h
21#define _vctFrame4x4Base_h
22
27
30
45template<class _containerType>
47 public vctFrame4x4ConstBase<_containerType>
48{
49public:
50 enum {ROWS = 4, COLS = 4};
51 enum {DIMENSION = 3};
52 typedef _containerType ContainerType;
55
56 /* define most types from vctContainerTraits */
57 VCT_CONTAINER_TRAITS_TYPEDEFS(typename ContainerType::value_type);
58
67 typedef typename BaseType::MatrixValueType MatrixValueType;
68
75
77
78public:
79
80
83 BaseType()
84 {}
85
86
88 return this->TranslationRef;
89 }
90
91 inline ConstRotationRefType Rotation(void) const {
92 return this->RotationRef;
93 }
94
96 return this->PerspectiveRef;
97 }
98
100 return this->TranslationRef;
101 }
102
104 return this->RotationRef;
105 }
106
108 return this->PerspectiveRef;
109 }
110
111
118 template <class __rotationType, class __translationType>
119 ThisType & From(const __rotationType & rotation,
120 const __translationType & translation)
121 CISST_THROW(std::runtime_error)
122 {
123 this->RotationRef.From(rotation);
124 this->TranslationRef.Assign(translation);
125 this->PerspectiveRef.SetAll(static_cast<value_type>(0.0));
126 this->Element(DIMENSION, DIMENSION) = static_cast<value_type>(1.0);
127 return *this;
128 }
129
130 template <class __rotationType, class __translationType>
131 ThisType & FromNormalized(const __rotationType & rotation,
132 const __translationType & translation)
133 {
134 this->RotationRef.FromNormalized(rotation);
135 this->TranslationRef.Assign(translation);
136 this->PerspectiveRef.SetAll(static_cast<value_type>(0.0));
137 this->Element(DIMENSION, DIMENSION) = static_cast<value_type>(1.0);
138 return *this;
139 }
140
141 template <class __rotationType, class __translationType>
142 ThisType & FromRaw(const __rotationType & rotation,
143 const __translationType & translation)
144 {
145 this->RotationRef.FromRaw(rotation);
146 this->TranslationRef.Assign(translation);
147 this->PerspectiveRef.SetAll(static_cast<value_type>(0.0));
148 this->Element(DIMENSION, DIMENSION) = static_cast<value_type>(1.0);
149 return *this;
150 }
151
152
153
161 template <class __rotationType>
163 CISST_THROW(std::runtime_error)
164 {
165 this->From(frame.Rotation(), frame.Translation());
166 return *this;
167 }
168
169 template <class __rotationType>
171 {
172 this->FromNormalized(frame.Rotation(), frame.Translation());
173 return *this;
174 }
175
176 template <class __rotationType>
178 {
179 this->FromRaw(frame.Rotation(), frame.Translation());
180 return *this;
181 }
182
183
184
191 this->Rotation().NormalizedSelf();
192 this->PerspectiveRef.SetAll(static_cast<value_type>(0.0));
193 this->Element(DIMENSION, DIMENSION) = static_cast<value_type>(1.0);
194 return *this;
195 }
196
197
199 inline ThisType & InverseSelf(void) {
200 // R -> Rinv
201 this->RotationRef.InverseSelf();
202 // T -> Rinv * (-T)
204 temp.Assign(this->TranslationRef);
205 temp.NegationSelf();
206 this->RotationRef.ApplyTo(temp, this->TranslationRef);
207 return *this;
208 }
209
210
211 template <class __containerType>
213 this->TranslationRef.Assign(otherFrame.Translation());
214 this->RotationRef.Assign(otherFrame.Rotation());
215 this->InverseSelf();
216 return *this;
217 }
218
219};
220
221
222#endif // _vctFrame4x4Base_h
A collection of useful information about the C++ basic types, represented in a generic programming wa...
Definition cmnTypeTraits.h:155
ThisType & Assign(const vctFixedSizeConstVectorBase< _size, __stride, __elementType, __dataPtrType > &other)
Definition vctFixedSizeVectorBase.h:274
ThisType & NegationSelf(void)
Definition vctFixedSizeVectorBase.h:1339
Implementation of a fixed-size vector using template metaprogramming.
Definition vctFixedSizeVector.h:54
TranslationRefType Translation(void)
Definition vctFrame4x4Base.h:99
BaseType::TranslationRefType TranslationRefType
Definition vctFrame4x4Base.h:69
RotationRefType Rotation(void)
Definition vctFrame4x4Base.h:103
ThisType & NormalizedSelf(void)
Definition vctFrame4x4Base.h:190
BaseType::ConstRefTransposeType ConstRefTransposeType
Definition vctFrame4x4Base.h:66
PerspectiveRefType Perspective(void)
Definition vctFrame4x4Base.h:107
BaseType::RowRefType RowRefType
Definition vctFrame4x4Base.h:59
@ COLS
Definition vctFrame4x4Base.h:50
@ ROWS
Definition vctFrame4x4Base.h:50
BaseType::ConstColumnRefType ConstColumnRefType
Definition vctFrame4x4Base.h:62
ContainerType ContainerType
Definition vctFrame4x4Base.h:52
ConstRotationRefType Rotation(void) const
Definition vctFrame4x4Base.h:91
BaseType::ConstRotationRefType ConstRotationRefType
Definition vctFrame4x4Base.h:74
BaseType::PerspectiveRefType PerspectiveRefType
Definition vctFrame4x4Base.h:71
BaseType::MatrixValueType MatrixValueType
Definition vctFrame4x4Base.h:67
BaseType::ConstPerspectiveRefType ConstPerspectiveRefType
Definition vctFrame4x4Base.h:72
ConstPerspectiveRefType Perspective(void) const
Definition vctFrame4x4Base.h:95
BaseType::RotationRefType RotationRefType
Definition vctFrame4x4Base.h:73
BaseType::ColumnRefType ColumnRefType
Definition vctFrame4x4Base.h:60
ThisType & FromNormalized(const __rotationType &rotation, const __translationType &translation)
Definition vctFrame4x4Base.h:131
vctFrame4x4Base(void)
Definition vctFrame4x4Base.h:82
BaseType::ConstTranslationRefType ConstTranslationRefType
Definition vctFrame4x4Base.h:70
BaseType::ConstRowRefType ConstRowRefType
Definition vctFrame4x4Base.h:61
BaseType::DiagonalRefType DiagonalRefType
Definition vctFrame4x4Base.h:63
VCT_CONTAINER_TRAITS_TYPEDEFS(typename ContainerType::value_type)
@ DIMENSION
Definition vctFrame4x4Base.h:51
ThisType & FromRaw(const __rotationType &rotation, const __translationType &translation)
Definition vctFrame4x4Base.h:142
ThisType & FromNormalized(const vctFrameBase< __rotationType > &frame)
Definition vctFrame4x4Base.h:170
ThisType & InverseOf(const vctFrame4x4ConstBase< __containerType > &otherFrame)
Definition vctFrame4x4Base.h:212
ConstTranslationRefType Translation(void) const
Definition vctFrame4x4Base.h:87
cmnTypeTraits< value_type > TypeTraits
Definition vctFrame4x4Base.h:76
ThisType & InverseSelf(void)
Definition vctFrame4x4Base.h:199
ThisType & FromRaw(const vctFrameBase< __rotationType > &frame)
Definition vctFrame4x4Base.h:177
ThisType & From(const vctFrameBase< __rotationType > &frame) CISST_THROW(std
Definition vctFrame4x4Base.h:162
BaseType::ConstDiagonalRefType ConstDiagonalRefType
Definition vctFrame4x4Base.h:64
BaseType::RefTransposeType RefTransposeType
Definition vctFrame4x4Base.h:65
vctFrame4x4Base< ContainerType > ThisType
Definition vctFrame4x4Base.h:54
ThisType & From(const __rotationType &rotation, const __translationType &translation) CISST_THROW(std
Definition vctFrame4x4Base.h:119
vctFrame4x4ConstBase< ContainerType > BaseType
Definition vctFrame4x4Base.h:53
ConstTranslationRefType Translation(void) const
Definition vctFrame4x4ConstBase.h:120
BaseType::ConstColumnRefType ConstColumnRefType
Definition vctFrame4x4ConstBase.h:69
BaseType::RefTransposeType RefTransposeType
Definition vctFrame4x4ConstBase.h:72
vctFixedSizeConstVectorRef< value_type, DIMENSION, ROWSTRIDE > ConstTranslationRefType
Definition vctFrame4x4ConstBase.h:80
BaseType::RowRefType RowRefType
Definition vctFrame4x4ConstBase.h:66
TranslationRefType TranslationRef
Definition vctFrame4x4ConstBase.h:90
vctFixedSizeVectorRef< value_type, DIMENSION, COLSTRIDE > PerspectiveRefType
Definition vctFrame4x4ConstBase.h:81
BaseType::DiagonalRefType DiagonalRefType
Definition vctFrame4x4ConstBase.h:70
vctFixedSizeConstVectorRef< value_type, DIMENSION, COLSTRIDE > ConstPerspectiveRefType
Definition vctFrame4x4ConstBase.h:82
BaseType::ConstDiagonalRefType ConstDiagonalRefType
Definition vctFrame4x4ConstBase.h:71
PerspectiveRefType PerspectiveRef
Definition vctFrame4x4ConstBase.h:91
vctFrame4x4ConstBase(void)
Definition vctFrame4x4ConstBase.h:110
BaseType::ColumnRefType ColumnRefType
Definition vctFrame4x4ConstBase.h:67
ConstRotationRefType Rotation(void) const
Definition vctFrame4x4ConstBase.h:124
vctFixedSizeVectorRef< value_type, DIMENSION, ROWSTRIDE > TranslationRefType
Definition vctFrame4x4ConstBase.h:79
vctMatrixRotation3Ref< value_type, ROWSTRIDE, COLSTRIDE > RotationRefType
Definition vctFrame4x4ConstBase.h:83
vctMatrixRotation3ConstRef< value_type, ROWSTRIDE, COLSTRIDE > ConstRotationRefType
Definition vctFrame4x4ConstBase.h:84
BaseType::ConstRefTransposeType ConstRefTransposeType
Definition vctFrame4x4ConstBase.h:73
RotationRefType RotationRef
Definition vctFrame4x4ConstBase.h:89
BaseType::ConstRowRefType ConstRowRefType
Definition vctFrame4x4ConstBase.h:68
Template base class for a frame.
Definition vctFrameBase.h:49
const RotationType & Rotation(void) const
Definition vctFrameBase.h:205
const TranslationType & Translation(void) const
Definition vctFrameBase.h:186
ThisType & FromNormalized(const vctMatrixRotation3Base< __containerType > &other) CISST_THROW(std
Definition vctMatrixRotation3Base.h:232
ThisType & From(const vctMatrixRotation3Base< __containerType > &other) CISST_THROW(std
Definition vctMatrixRotation3Base.h:106
ThisType & FromRaw(const vctMatrixRotation3Base< __containerType > &other) CISST_THROW(std
Definition vctMatrixRotation3Base.h:352
ThisType & NormalizedSelf(void)
Definition vctMatrixRotation3Base.h:491
ThisType & InverseSelf(void)
Definition vctMatrixRotation3Base.h:513
void ApplyTo(const vctFixedSizeConstVectorBase< DIMENSION, __stride1, value_type, __dataPtrType1 > &input, vctFixedSizeVectorBase< DIMENSION, __stride2, value_type, __dataPtrType2 > &output) const
Definition vctMatrixRotation3ConstBase.h:156
#define CISST_THROW(exceptionParameter)
Somewhat portable compilation warning message. This works with very recent versions of gcc (4....
Definition cmnPortability.h:559
const_reference Element(size_type rowIndex, size_type colIndex) const
Definition vctDynamicConstMatrixBase.h:362
Macros to export the symbols of cisstVector (in a Dll).
Declaration of vctFrame4x4Base.