cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
6  Author(s): Anton Deguet
7  Created on: 2007-09-13
8 
9  (C) Copyright 2007-2012 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 #pragma once
22 #ifndef _vctFrame4x4Base_h
23 #define _vctFrame4x4Base_h
24 
31 #include <cisstVector/vctExport.h>
32 
47 template<class _containerType>
48 class vctFrame4x4Base:
49  public vctFrame4x4ConstBase<_containerType>
50 {
51 public:
52  enum {ROWS = 4, COLS = 4};
53  enum {DIMENSION = 3};
54  typedef _containerType ContainerType;
57 
58  /* define most types from vctContainerTraits */
59  VCT_CONTAINER_TRAITS_TYPEDEFS(typename ContainerType::value_type);
60 
61  typedef typename BaseType::RowRefType RowRefType;
69  typedef typename BaseType::MatrixValueType MatrixValueType;
70 
71  typedef typename BaseType::TranslationRefType TranslationRefType;
72  typedef typename BaseType::ConstTranslationRefType ConstTranslationRefType;
73  typedef typename BaseType::PerspectiveRefType PerspectiveRefType;
74  typedef typename BaseType::ConstPerspectiveRefType ConstPerspectiveRefType;
75  typedef typename BaseType::RotationRefType RotationRefType;
76  typedef typename BaseType::ConstRotationRefType ConstRotationRefType;
77 
79 
80 public:
81 
82 
85  BaseType()
86  {}
87 
88 
89  inline ConstTranslationRefType Translation(void) const {
90  return this->TranslationRef;
91  }
92 
93  inline ConstRotationRefType Rotation(void) const {
94  return this->RotationRef;
95  }
96 
97  inline ConstPerspectiveRefType Perspective(void) const {
98  return this->PerspectiveRef;
99  }
100 
102  return this->TranslationRef;
103  }
104 
105  inline RotationRefType Rotation(void) {
106  return this->RotationRef;
107  }
108 
110  return this->PerspectiveRef;
111  }
112 
113 
120  template <class __rotationType, class __translationType>
121  ThisType & From(const __rotationType & rotation,
122  const __translationType & translation)
123  throw (std::runtime_error)
124  {
125  this->RotationRef.From(rotation);
126  this->TranslationRef.Assign(translation);
127  this->PerspectiveRef.SetAll(static_cast<value_type>(0.0));
128  this->Element(DIMENSION, DIMENSION) = static_cast<value_type>(1.0);
129  return *this;
130  }
131 
132  template <class __rotationType, class __translationType>
133  ThisType & FromNormalized(const __rotationType & rotation,
134  const __translationType & translation)
135  {
136  this->RotationRef.FromNormalized(rotation);
137  this->TranslationRef.Assign(translation);
138  this->PerspectiveRef.SetAll(static_cast<value_type>(0.0));
139  this->Element(DIMENSION, DIMENSION) = static_cast<value_type>(1.0);
140  return *this;
141  }
142 
143  template <class __rotationType, class __translationType>
144  ThisType & FromRaw(const __rotationType & rotation,
145  const __translationType & translation)
146  {
147  this->RotationRef.FromRaw(rotation);
148  this->TranslationRef.Assign(translation);
149  this->PerspectiveRef.SetAll(static_cast<value_type>(0.0));
150  this->Element(DIMENSION, DIMENSION) = static_cast<value_type>(1.0);
151  return *this;
152  }
154 
155 
163  template <class __rotationType>
165  throw (std::runtime_error)
166  {
167  this->From(frame.Rotation(), frame.Translation());
168  return *this;
169  }
170 
171  template <class __rotationType>
173  {
174  this->FromNormalized(frame.Rotation(), frame.Translation());
175  return *this;
176  }
177 
178  template <class __rotationType>
180  {
181  this->FromRaw(frame.Rotation(), frame.Translation());
182  return *this;
183  }
185 
186 
193  this->Rotation().NormalizedSelf();
194  this->PerspectiveRef.SetAll(static_cast<value_type>(0.0));
195  this->Element(DIMENSION, DIMENSION) = static_cast<value_type>(1.0);
196  return *this;
197  }
198 
199 
201  inline ThisType & InverseSelf(void) {
202  // R -> Rinv
203  this->RotationRef.InverseSelf();
204  // T -> Rinv * (-T)
206  temp.Assign(this->TranslationRef);
207  temp.NegationSelf();
208  this->RotationRef.ApplyTo(temp, this->TranslationRef);
209  return *this;
210  }
211 
212 
213  template <class __containerType>
215  this->TranslationRef.Assign(otherFrame.Translation());
216  this->RotationRef.Assign(otherFrame.Rotation());
217  this->InverseSelf();
218  return *this;
219  }
220 
221 };
222 
223 
224 #endif // _vctFrame4x4Base_h
Template base class for a 4x4 frame.
Definition: vctForwardDeclarations.h:234
A template for a fixed size matrix with fixed spacing in memory.
Definition: vctFixedSizeConstMatrixBase.h:103
ThisType & FromNormalized(const __rotationType &rotation, const __translationType &translation)
Definition: vctFrame4x4Base.h:133
ThisType & InverseSelf(void)
Definition: vctFrame4x4Base.h:201
vctFrame4x4ConstBase< ContainerType > BaseType
Definition: vctFrame4x4Base.h:55
ThisType & From(const __rotationType &rotation, const __translationType &translation)
Definition: vctFrame4x4Base.h:121
ThisType & From(const vctFrameBase< __rotationType > &frame)
Definition: vctFrame4x4Base.h:164
An implementation of the ``abstract'' vctFixedSizeVectorBase.
Definition: vctFixedSizeVectorRef.h:46
BaseType::ConstRefTransposeType ConstRefTransposeType
Definition: vctFrame4x4Base.h:68
BaseType::ConstRotationRefType ConstRotationRefType
Definition: vctFrame4x4Base.h:76
BaseType::ConstTranslationRefType ConstTranslationRefType
Definition: vctFrame4x4Base.h:72
cmnTypeTraits< value_type > TypeTraits
Definition: vctFrame4x4Base.h:78
An implementation of the ``abstract'' vctFixedSizeConstVectorBase.
Definition: vctFixedSizeConstVectorRef.h:50
ThisType & FromNormalized(const vctFrameBase< __rotationType > &frame)
Definition: vctFrame4x4Base.h:172
BaseType::ConstDiagonalRefType ConstDiagonalRefType
Definition: vctFrame4x4Base.h:66
BaseType::ConstRowRefType ConstRowRefType
Definition: vctFrame4x4Base.h:63
BaseType::ColumnRefType ColumnRefType
Definition: vctFrame4x4Base.h:62
Template base class for a 4x4 frame.
Definition: vctForwardDeclarations.h:235
ThisType & Assign(const vctFixedSizeConstVectorBase< _size, __stride, __elementType, __dataPtrType > &other)
Definition: vctFixedSizeVectorBase.h:274
Definition: vctFrame4x4Base.h:52
_containerType ContainerType
Definition: vctFrame4x4Base.h:54
ThisType & FromRaw(const vctFrameBase< __rotationType > &frame)
Definition: vctFrame4x4Base.h:179
Declaration of vctFrame4x4Base.
A template for a fixed size matrix with fixed spacings in memory.
Definition: vctFixedSizeMatrixBase.h:58
Definition: vctFrame4x4Base.h:53
ThisType & InverseOf(const vctFrame4x4ConstBase< __containerType > &otherFrame)
Definition: vctFrame4x4Base.h:214
ConstPerspectiveRefType Perspective(void) const
Definition: vctFrame4x4Base.h:97
RotationRefType Rotation(void)
Definition: vctFrame4x4Base.h:105
BaseType::PerspectiveRefType PerspectiveRefType
Definition: vctFrame4x4Base.h:73
An implementation of the ``abstract'' vctFixedSizeMatrixBase.
Definition: vctFixedSizeMatrixRef.h:46
ConstTranslationRefType Translation(void) const
Definition: vctFrame4x4Base.h:89
const TranslationType & Translation(void) const
Definition: vctFrameBase.h:188
BaseType::RefTransposeType RefTransposeType
Definition: vctFrame4x4Base.h:67
ConstRotationRefType Rotation(void) const
Definition: vctFrame4x4Base.h:93
PerspectiveRefType Perspective(void)
Definition: vctFrame4x4Base.h:109
ConstRotationRefType Rotation(void) const
Definition: vctFrame4x4ConstBase.h:124
BaseType::DiagonalRefType DiagonalRefType
Definition: vctFrame4x4Base.h:65
BaseType::TranslationRefType TranslationRefType
Definition: vctFrame4x4Base.h:71
BaseType::RowRefType RowRefType
Definition: vctFrame4x4Base.h:61
BaseType::RotationRefType RotationRefType
Definition: vctFrame4x4Base.h:75
BaseType::MatrixValueType MatrixValueType
Definition: vctFrame4x4Base.h:69
ThisType & NegationSelf(void)
Definition: vctFixedSizeVectorBase.h:1339
void ApplyTo(const vctFixedSizeConstVectorBase< DIMENSION, __stride1, value_type, __dataPtrType1 > &input, vctFixedSizeVectorBase< DIMENSION, __stride2, value_type, __dataPtrType2 > &output) const
Definition: vctFrame4x4ConstBase.h:161
ThisType & NormalizedSelf(void)
Definition: vctFrame4x4Base.h:192
vctFrame4x4Base< ContainerType > ThisType
Definition: vctFrame4x4Base.h:56
BaseType::ConstPerspectiveRefType ConstPerspectiveRefType
Definition: vctFrame4x4Base.h:74
An implementation of the ``abstract'' vctFixedSizeConstMatrixBase.
Definition: vctFixedSizeConstMatrixRef.h:50
TranslationRefType Translation(void)
Definition: vctFrame4x4Base.h:101
Template base class for a frame.
Definition: vctForwardDeclarations.h:232
ConstTranslationRefType Translation(void) const
Definition: vctFrame4x4ConstBase.h:120
Macros to export the symbols of cisstVector (in a Dll).
A collection of useful information about the C++ basic types, represented in a generic programming wa...
Definition: cmnTypeTraits.h:155
BaseType::ConstColumnRefType ConstColumnRefType
Definition: vctFrame4x4Base.h:64
VCT_CONTAINER_TRAITS_TYPEDEFS(typename ContainerType::value_type)
Definition: vctFrame4x4Base.h:52
const RotationType & Rotation(void) const
Definition: vctFrameBase.h:196
ThisType & FromRaw(const __rotationType &rotation, const __translationType &translation)
Definition: vctFrame4x4Base.h:144
vctFrame4x4Base(void)
Definition: vctFrame4x4Base.h:84