MathUtilities.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_TESTING_MATHUTILITIES_H
#define SURGSIM_TESTING_MATHUTILITIES_H
#include <utility>
#include "SurgSim/Math/RigidTransform.h"
#include "SurgSim/Math/Vector.h"
#include "SurgSim/Math/Quaternion.h"
#include <Eigen/Geometry>
namespace SurgSim
{
namespace Testing
{
template <class T>
T interpolate(const T& start, const T& end, const double& t)
{
return (1 - t) * start + t * end;
}
template <class T>
T interpolate(const std::pair<T, T>& values, const double& t)
{
return interpolate<T>(values.first, values.second, t);
}
template <>
SurgSim::Math::Quaterniond interpolate<SurgSim::Math::Quaterniond>(
const SurgSim::Math::Quaterniond& start,
const SurgSim::Math::Quaterniond& end,
const double& t);
template <>
SurgSim::Math::RigidTransform3d interpolate<SurgSim::Math::RigidTransform3d>(
const SurgSim::Math::RigidTransform3d& start,
const SurgSim::Math::RigidTransform3d& end,
const double& t);
SurgSim::Math::RigidTransform3d interpolatePose(
const SurgSim::Math::Vector3d& startAngles,
const SurgSim::Math::Vector3d& endAngles,
const SurgSim::Math::Vector3d& startPosition,
const SurgSim::Math::Vector3d& endPosition,
const double& t);
}
}
namespace Eigen
{
template<class T, int Dim>
::std::ostream& operator<<(::std::ostream& os, const Eigen::AlignedBox<T, Dim>& box)
{
os << "[" << box.min().transpose() << ", " << box.max().transpose() << "]";
return os;
}
}
#endif
Quaternion.h
Definitions of quaternion types.
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
Eigen
Definition: MathUtilities.h:94
SurgSim::Testing::interpolatePose
SurgSim::Math::RigidTransform3d interpolatePose(const Vector3d &startAngles, const Vector3d &endAngles, const Vector3d &startPosition, const Vector3d &endPosition, const double &t)
Definition: MathUtilities.cpp:32
RigidTransform.h
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
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::Testing::interpolate
SurgSim::Math::Quaterniond interpolate(const SurgSim::Math::Quaterniond &start, const SurgSim::Math::Quaterniond &end, const double &t)
Definition: MathUtilities.cpp:49
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57