OSVR-Core
AngVelTools.h
Go to the documentation of this file.
1 
11 // Copyright 2016 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_AngVelTools_h_GUID_628878EF_DAFC_4486_36BC_6C47BD452AB0
26 #define INCLUDED_AngVelTools_h_GUID_628878EF_DAFC_4486_36BC_6C47BD452AB0
27 
28 // Internal Includes
29 // - none
30 
31 // Library/third-party includes
34 
35 // Standard includes
36 #include <cmath>
37 
38 namespace osvr {
39 namespace vbtracker {
41  inline Eigen::Quaterniond
42  angVelVecToIncRot(Eigen::Vector3d const &angVelVec, double dt) {
43  return util::quat_exp(angVelVec * dt * 0.5).normalized();
44  }
45 
47  inline Eigen::Vector3d incRotToAngVelVec(Eigen::Quaterniond const &incRot,
48  double dt) {
49 #if 0
50  if (incRot.w() >= 1. || incRot.vec().isZero(1e-10)) {
51  return Eigen::Vector3d::Zero();
52  }
53  auto angle = std::acos(incRot.w());
54  return incRot.vec().normalized() * angle * 2. / dt;
55 #else
56  return util::quat_ln(incRot) * 2. / dt;
57 #endif
58  }
59 
60 } // namespace vbtracker
61 } // namespace osvr
62 #endif // INCLUDED_AngVelTools_h_GUID_628878EF_DAFC_4486_36BC_6C47BD452AB0
Eigen::Quaterniond angVelVecToIncRot(Eigen::Vector3d const &angVelVec, double dt)
use only for derivatives - has factor of 2/0.5 in it!
Definition: AngVelTools.h:42
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.
const Block< const Coefficients, 3, 1 > vec() const
Definition: Quaternion.h:87
Eigen::Vector3d incRotToAngVelVec(Eigen::Quaterniond const &incRot, double dt)
use only for derivatives - has factor of 2/0.5 in it!
Definition: AngVelTools.h:47
Scalar w() const
Definition: Quaternion.h:75
Definition: Quaternion.h:47
Quaternion normalized() const
Definition: Quaternion.h:154