All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OsgQuaternionConversions.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
23 
24 #ifndef SURGSIM_GRAPHICS_OSGQUATERNIONCONVERSIONS_H
25 #define SURGSIM_GRAPHICS_OSGQUATERNIONCONVERSIONS_H
26 
28 
29 #include <osg/Quat>
30 
31 namespace SurgSim
32 {
33 
34 namespace Graphics
35 {
36 
38 inline osg::Quat toOsg(const SurgSim::Math::Quaternionf& quaternion)
39 {
40  return osg::Quat(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w());
41 }
42 
44 inline osg::Quat toOsg(const SurgSim::Math::Quaterniond& quaternion)
45 {
46  return osg::Quat(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w());
47 }
48 
51 template <typename T> inline
52 Eigen::Quaternion<T> fromOsg(const osg::Quat& quaternion)
53 {
54  return Eigen::Quaternion<T>(quaternion.w(), quaternion.x(), quaternion.y(), quaternion.z());
55 }
56 
57 }; // namespace Graphics
58 
59 }; // namespace SurgSim
60 
61 #endif // SURGSIM_GRAPHICS_OSGQUATERNIONCONVERSIONS_H
Definitions of quaternion types.
const Eigen::Matrix< float, 2, 2, Eigen::RowMajor > fromOsg(const osg::Matrix2 &matrix)
Convert from OSG to a 2x2 matrix of floats.
Definition: OsgMatrixConversions.h:73
const osg::Matrix2 toOsg(const Eigen::Matrix< float, 2, 2, MOpt > &matrix)
Convert a fixed-size 2x2 matrix of floats to OSG.
Definition: OsgMatrixConversions.h:56
Eigen::Quaternion< double > Quaterniond
A quaternion of doubles.
Definition: Quaternion.h:38
Eigen::Quaternion< float > Quaternionf
A quaternion of floats.
Definition: Quaternion.h:34