OSVR-Core
ChangeOfBasis.h
Go to the documentation of this file.
1 
11 // Copyright 2014 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_ChangeOfBasis_h_GUID_3821B5B4_4DC3_4C94_71A5_3D05E043CC62
26 #define INCLUDED_ChangeOfBasis_h_GUID_3821B5B4_4DC3_4C94_71A5_3D05E043CC62
27 
28 // Internal Includes
29 #include <osvr/Util/StdInt.h>
30 #include <osvr/Common/Transform.h>
31 
32 // Library/third-party includes
34 
35 // Standard includes
36 // - none
37 
38 namespace osvr {
39 namespace common {
40  class ChangeOfBasis {
41  public:
42  ChangeOfBasis() : m_xform(Eigen::Matrix4d::Zero()) {
43  m_xform(3, 3) = 1;
44  }
45  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
46 
47  void setNewX(Eigen::Vector3d const &oldVec) { m_setNew(0, oldVec); }
48  void setNewY(Eigen::Vector3d const &oldVec) { m_setNew(1, oldVec); }
49  void setNewZ(Eigen::Vector3d const &oldVec) { m_setNew(2, oldVec); }
50 
51  Transform get() const {
52  return Transform(m_xform.transpose(), m_xform);
53  }
54 
55  private:
56  void m_setNew(uint8_t newAxis, Eigen::Vector3d const &oldVec) {
57  m_xform.block<1, 3>(newAxis, 0) = oldVec.transpose();
58  }
59  Eigen::Matrix4d m_xform;
60  };
61 } // namespace common
62 } // namespace osvr
63 
64 #endif // INCLUDED_ChangeOfBasis_h_GUID_3821B5B4_4DC3_4C94_71A5_3D05E043CC62
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
Header.
Header wrapping the C99 standard stdint header.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Header wrapping include of <Eigen/Core> and <Eigen/Geometry> for warning quieting.
Definition: ChangeOfBasis.h:40
Spatial transformation, consisting of both pre and post components.
Definition: Transform.h:44