OsgQuaternionConversions.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_OSGQUATERNIONCONVERSIONS_H
#define SURGSIM_GRAPHICS_OSGQUATERNIONCONVERSIONS_H
#include "SurgSim/Math/Quaternion.h"
#include <osg/Quat>
namespace SurgSim
{
namespace Graphics
{
inline osg::Quat toOsg(const SurgSim::Math::Quaternionf& quaternion)
{
return osg::Quat(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w());
}
inline osg::Quat toOsg(const SurgSim::Math::Quaterniond& quaternion)
{
return osg::Quat(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w());
}
template <typename T> inline
Eigen::Quaternion<T> fromOsg(const osg::Quat& quaternion)
{
return Eigen::Quaternion<T>(quaternion.w(), quaternion.x(), quaternion.y(), quaternion.z());
}
}; // namespace Graphics
}; // namespace SurgSim
#endif // SURGSIM_GRAPHICS_OSGQUATERNIONCONVERSIONS_H
Quaternion.h
Definitions of quaternion types.
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::fromOsg
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
SurgSim::Graphics::toOsg
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
SurgSim::Math::Quaterniond
Eigen::Quaternion< double > Quaterniond
A quaternion of doubles.
Definition: Quaternion.h:38
SurgSim::Math::Quaternionf
Eigen::Quaternion< float > Quaternionf
A quaternion of floats.
Definition: Quaternion.h:34