OsgRigidTransformConversions.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_OSGRIGIDTRANSFORMCONVERSIONS_H
#define SURGSIM_GRAPHICS_OSGRIGIDTRANSFORMCONVERSIONS_H
#include "SurgSim/Graphics/OsgQuaternionConversions.h"
#include "SurgSim/Graphics/OsgVectorConversions.h"
#include "SurgSim/Math/Quaternion.h"
#include "SurgSim/Math/RigidTransform.h"
#include "SurgSim/Math/Vector.h"
#include <osg/Quat>
#include <osg/Vec2>
#include <osg/Vec3>
namespace SurgSim
{
namespace Graphics
{
inline std::pair<osg::Quat, osg::Vec3f> toOsg(const SurgSim::Math::RigidTransform3f& transform)
{
SurgSim::Math::Quaternionf normalizedQuaternion = SurgSim::Math::Quaternionf(transform.linear()).normalized();
return std::make_pair(toOsg(normalizedQuaternion), toOsg(SurgSim::Math::Vector3f(transform.translation())));
}
inline std::pair<osg::Quat, osg::Vec3d> toOsg(const SurgSim::Math::RigidTransform3d& transform)
{
SurgSim::Math::Quaterniond normalizedQuaternion = SurgSim::Math::Quaterniond(transform.linear()).normalized();
return std::make_pair(toOsg(normalizedQuaternion), toOsg(SurgSim::Math::Vector3d(transform.translation())));
}
inline SurgSim::Math::RigidTransform3f fromOsg(const osg::Quat& rotation, const osg::Vec3f& translation)
{
return SurgSim::Math::makeRigidTransform(fromOsg<float>(rotation), fromOsg(translation));
}
inline SurgSim::Math::RigidTransform3f fromOsg(const std::pair<osg::Quat, osg::Vec3f>& transform)
{
return fromOsg(transform.first, transform.second);
}
inline SurgSim::Math::RigidTransform3d fromOsg(const osg::Quat& rotation, const osg::Vec3d& translation)
{
return SurgSim::Math::makeRigidTransform(fromOsg<double>(rotation), fromOsg(translation));
}
inline SurgSim::Math::RigidTransform3d fromOsg(const std::pair<osg::Quat, osg::Vec3d>& transform)
{
return fromOsg(transform.first, transform.second);
}
}; // namespace Graphics
}; // namespace SurgSim
#endif // SURGSIM_GRAPHICS_OSGRIGIDTRANSFORMCONVERSIONS_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::Math::RigidTransform3f
Eigen::Transform< float, 3, Eigen::Isometry > RigidTransform3f
A 3D rigid (isometric) transform, represented as floats.
Definition: RigidTransform.h:38
SurgSim::Math::makeRigidTransform
Eigen::Transform< typename M::Scalar, M::RowsAtCompileTime, Eigen::Isometry > makeRigidTransform(const Eigen::MatrixBase< M > &rotation, const Eigen::MatrixBase< V > &translation)
Create a rigid transform using the specified rotation matrix and translation.
Definition: RigidTransform.h:56
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::Vector3f
Eigen::Matrix< float, 3, 1 > Vector3f
A 3D vector of floats.
Definition: Vector.h:41
OsgVectorConversions.h
Conversions to and from OSG vector types.
RigidTransform.h
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
OsgQuaternionConversions.h
Conversions to and from OSG quaternion types.
SurgSim::Math::Quaterniond
Eigen::Quaternion< double > Quaterniond
A quaternion of doubles.
Definition: Quaternion.h:38
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Math::Quaternionf
Eigen::Quaternion< float > Quaternionf
A quaternion of floats.
Definition: Quaternion.h:34
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57