OSVR-Core
ExtractYaw.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_ExtractYaw_h_GUID_D9365866_476B_429D_7216_17299B9CB5C6
26 #define INCLUDED_ExtractYaw_h_GUID_D9365866_476B_429D_7216_17299B9CB5C6
27 
28 // Internal Includes
29 // - none
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 #include <cmath>
36 
37 namespace osvr {
38 namespace util {
46  template <typename T>
47  inline auto extractYaw(T const &quat) -> decltype(std::atan(quat.w())) {
48  auto yaw =
49  std::atan2(2 * (quat.y() * quat.w() - quat.x() * quat.z()),
50  1 - 2 * quat.y() * quat.y() - 2 * quat.z() * quat.z());
51  return yaw;
52  }
53 } // namespace util
54 } // namespace osvr
55 #endif // INCLUDED_ExtractYaw_h_GUID_D9365866_476B_429D_7216_17299B9CB5C6
Definition: RunLoopManager.h:42
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
auto extractYaw(T const &quat) -> decltype(std::atan(quat.w()))
A utility function to extract "yaw" out of a quaternion, of any representation as long as it responds...
Definition: ExtractYaw.h:47
A small structure to hold a non zero as a triplet (i,j,value).
Definition: SparseUtil.h:148