OSVR-Core
ExternalQuaternion.h
Go to the documentation of this file.
1 
11 // Copyright 2015 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_ExternalQuaternion_h_GUID_3235DD66_A6E6_47BD_7CC0_51BBF45EF38D
26 #define INCLUDED_ExternalQuaternion_h_GUID_3235DD66_A6E6_47BD_7CC0_51BBF45EF38D
27 
28 // Internal Includes
29 #include "FlexibleKalmanBase.h"
30 
31 // Library/third-party includes
33 
34 // Standard includes
35 #include <type_traits>
36 #include <cassert>
37 
38 namespace osvr {
39 namespace kalman {
40  namespace external_quat {
45  inline Eigen::Quaterniond vecToQuat(types::Vector<3> const &incRotVec) {
46  return util::quat_exp(incRotVec / 2.);
47  }
50 #if 0
51  inline types::Matrix<4, 3> jacobian(Eigen::Vector3d const &incRotVec) {
52  assert(vecToQuatScalarPartSquared(incRotVec) >= 0 &&
53  "Incremental rotation vector's squared norm was greater "
54  "than 1! Precondition fail!");
55  // eigen internally stores quaternions x, y, z, w
57  // vector components of jacobian are all 1/2 identity
58  ret.topLeftCorner<3, 3>() =
60  ret.bottomRows<1>() =
61  incRotVec.transpose() /
62  (-4. * std::sqrt(vecToQuatScalarPartSquared(incRotVec)));
63  return ret;
64  }
65 #endif
66 #if 0
67  inline types::Matrix<4, 3> jacobian(Eigen::Vector3d const &w) {
68  double a = w.squaredNorm() / 48 + 0.5;
69  // outer product over 24, plus a on the diagonal
70  Eigen::Matrix3d topBlock =
71  (w * w.transpose()) / 24. + Eigen::Matrix3d::Identity() * a;
72  // this weird thing on the bottom row.
73  Eigen::RowVector3d bottomRow =
74  (Eigen::Vector3d(2 * a, 0, 0) + (w[0] * w) / 12 - w / 4)
75  .transpose();
77  ret << topBlock, bottomRow;
78  return ret;
79  }
80 #endif
81  } // namespace external_quat
82 } // namespace kalman
83 } // namespace osvr
84 
85 #endif // INCLUDED_ExternalQuaternion_h_GUID_3235DD66_A6E6_47BD_7CC0_51BBF45EF38D
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Eigen::Quaterniond vecToQuat(types::Vector< 3 > const &incRotVec)
For use in maintaining an "external quaternion" and 3 incremental orientations, as done by Welch base...
Definition: ExternalQuaternion.h:45
Definition: Quaternion.h:47
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127