All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
SurgSim::Math Namespace Reference

Namespaces

 Geometry
 

Classes

class  BoxShape
 Box shape: box centered on (0 0 0), aligned with the axis with different sizes along X, Y and Z. More...
 
class  CapsuleShape
 Capsule shape: centered on (0, 0, 0), aligned along Y, with length and radius. More...
 
class  CylinderShape
 Cylinder shape: centered on (0 0 0), aligned along Y, defined with length and radius. More...
 
class  DoubleSidedPlaneShape
 DoubleSidedPlaneShape: The XZ plane (d = 0) with normal pointing along positive Y axis. More...
 
struct  gaussQuadraturePoint
 
class  LinearSolveAndInverse
 LinearSolveAndInverse aims at performing an efficient linear system resolution and calculating its inverse matrix at the same time. More...
 
class  LinearSolveAndInverseDenseMatrix
 Derivation for dense matrix type. More...
 
class  LinearSolveAndInverseDiagonalMatrix
 Derivation for diagonal matrix type. More...
 
class  LinearSolveAndInverseSymmetricTriDiagonalBlockMatrix
 Derivation for symmetric tri-diagonal block matrix type. More...
 
class  LinearSolveAndInverseTriDiagonalBlockMatrix
 Derivation for tri-diagonal block matrix type. More...
 
class  MeshShape
 Mesh shape: shape made of a triangle mesh The triangle mesh needs to be watertight to produce valid volume, center and second moment of volume. More...
 
class  MlcpGaussSeidelSolver
 A solver for mixed LCP problems using the Gauss-Seidel iterative method. More...
 
struct  MlcpProblem
 A description of an MLCP (mixed linear complementarity problem, or mixed LCP) system to be solved. More...
 
struct  MlcpSolution
 The description of a solution to a mixed linear complementarity problem. More...
 
class  MlcpSolver
 This class provides a solver interface for mixed linear complementarity problems. More...
 
class  OctreeShape
 Octree Shape A defined by an octree data structure. More...
 
class  OdeEquation
 Ode equation of 2nd order of the form M(x,v).a = F(x, v) with (x0, v0) for initial conditions and a set of boundary conditions. More...
 
class  OdeSolver
 Base class for all solvers of ode equation of order 2 of the form M(x(t), v(t)).a(t) = f(t, x(t), v(t)) More...
 
class  OdeSolverEulerExplicit
 Euler Explicit ode solver. More...
 
class  OdeSolverEulerExplicitModified
 Euler Explicit Modified ode solver. More...
 
class  OdeSolverEulerImplicit
 Euler Implicit ode solver. More...
 
class  OdeSolverLinearEulerExplicit
 Linear Version of the Euler Explicit ode solver This solver assumes that the system is linear, ie that Mass, Damping, and Stiffness matrices do not change. More...
 
class  OdeSolverLinearEulerExplicitModified
 Linear Version of the Modified Euler Explicit ode solver This solver assumes that the system is linear, ie that Mass, Damping, and Stiffness matrices do not change. More...
 
class  OdeSolverLinearEulerImplicit
 Linear Version of the Euler Implicit ode solver This solver assumes that the system is linear, ie that Mass, Damping, and Stiffness matrices do not change. More...
 
class  OdeSolverLinearRungeKutta4
 Linear Version of the Runge Kutta 4 ode solver This solver assumes that the system is linear ie that Mass, Damping, and Stiffness matrices do not change. More...
 
class  OdeSolverLinearStatic
 Linear version of the static ode solver This solver assumes that the system is linear, ie that Stiffness matrix does not change. More...
 
class  OdeSolverRungeKutta4
 Runge Kutta 4 ode solver See http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods. More...
 
class  OdeSolverStatic
 Static ode solver. More...
 
class  OdeState
 OdeState defines the state y of an ode of 2nd order of the form M(x,v).a = F(x, v) with boundary conditions. More...
 
class  PlaneShape
 The XZ plane (d = 0) with normal pointing along positive Y axis. More...
 
class  Shape
 Generic rigid shape class defining a shape. More...
 
class  SphereShape
 Sphere shape: sphere centered on (0 0 0), defined with radius. More...
 
class  SurfaceMeshShape
 SurfaceMeshShape defines a shape based on a mesh, like MeshShape. More...
 
class  TriangleHelper
 A helper class for a triangle, used for the following two purposes: More...
 

Typedefs

typedef Eigen::AlignedBox
< float, 3 > 
Aabbf
 Wrapper around the Eigen type. More...
 
typedef Eigen::AlignedBox
< double, 3 > 
Aabbd
 Wrapper around the Eigen type. More...
 
typedef Eigen::Matrix< float,
2, 2, Eigen::RowMajor > 
Matrix22f
 A 2x2 matrix of floats. More...
 
typedef Eigen::Matrix< float,
3, 3, Eigen::RowMajor > 
Matrix33f
 A 3x3 matrix of floats. More...
 
typedef Eigen::Matrix< float,
4, 4, Eigen::RowMajor > 
Matrix44f
 A 4x4 matrix of floats. More...
 
typedef Eigen::Matrix< double,
2, 2, Eigen::RowMajor > 
Matrix22d
 A 2x2 matrix of doubles. More...
 
typedef Eigen::Matrix< double,
3, 3, Eigen::RowMajor > 
Matrix33d
 A 3x3 matrix of doubles. More...
 
typedef Eigen::Matrix< double,
4, 4, Eigen::RowMajor > 
Matrix44d
 A 4x4 matrix of doubles. More...
 
typedef Eigen::Matrix< double,
6, 6, Eigen::RowMajor > 
Matrix66d
 A 6x6 matrix of doubles. More...
 
typedef Eigen::DiagonalMatrix
< double, Eigen::Dynamic > 
DiagonalMatrix
 A dynamic size diagonal matrix. More...
 
typedef Eigen::Matrix< double,
Eigen::Dynamic, Eigen::Dynamic > 
Matrix
 A dynamic size matrix. More...
 
typedef Eigen::Quaternion< float > Quaternionf
 A quaternion of floats. More...
 
typedef Eigen::Quaternion< double > Quaterniond
 A quaternion of doubles. More...
 
typedef Eigen::Transform
< float, 2, Eigen::Isometry > 
RigidTransform2f
 A 2D rigid (isometric) transform, represented as floats. More...
 
typedef Eigen::Transform
< float, 3, Eigen::Isometry > 
RigidTransform3f
 A 3D rigid (isometric) transform, represented as floats. More...
 
typedef Eigen::Transform
< double, 2, Eigen::Isometry > 
RigidTransform2d
 A 2D rigid (isometric) transform, represented as doubles. More...
 
typedef Eigen::Transform
< double, 3, Eigen::Isometry > 
RigidTransform3d
 A 3D rigid (isometric) transform, represented as doubles. More...
 
typedef Eigen::Matrix< float, 2, 1 > Vector2f
 A 2D vector of floats. More...
 
typedef Eigen::Matrix< float, 3, 1 > Vector3f
 A 3D vector of floats. More...
 
typedef Eigen::Matrix< float, 4, 1 > Vector4f
 A 4D vector of floats. More...
 
typedef Eigen::Matrix< float, 6, 1 > Vector6f
 A 6D vector of floats. More...
 
typedef Eigen::Matrix< double, 2, 1 > Vector2d
 A 2D vector of doubles. More...
 
typedef Eigen::Matrix< double, 3, 1 > Vector3d
 A 3D vector of doubles. More...
 
typedef Eigen::Matrix< double, 4, 1 > Vector4d
 A 4D vector of doubles. More...
 
typedef Eigen::Matrix< double, 6, 1 > Vector6d
 A 6D matrix of doubles. More...
 
typedef Eigen::Matrix< double,
Eigen::Dynamic, 1 > 
Vector
 A dynamic size column vector. More...
 

Enumerations

enum  MlcpConstraintType {
  MLCP_INVALID_CONSTRAINT = -1, MLCP_BILATERAL_1D_CONSTRAINT = 0, MLCP_BILATERAL_2D_CONSTRAINT, MLCP_BILATERAL_3D_CONSTRAINT,
  MLCP_UNILATERAL_3D_FRICTIONLESS_CONSTRAINT, MLCP_UNILATERAL_3D_FRICTIONAL_CONSTRAINT, MLCP_BILATERAL_FRICTIONLESS_SLIDING_CONSTRAINT, MLCP_BILATERAL_FRICTIONAL_SLIDING_CONSTRAINT,
  MLCP_NUM_CONSTRAINT_TYPES
}
 
enum  IntegrationScheme {
  INTEGRATIONSCHEME_STATIC = 0, INTEGRATIONSCHEME_LINEAR_STATIC, INTEGRATIONSCHEME_EXPLICIT_EULER, INTEGRATIONSCHEME_LINEAR_EXPLICIT_EULER,
  INTEGRATIONSCHEME_MODIFIED_EXPLICIT_EULER, INTEGRATIONSCHEME_LINEAR_MODIFIED_EXPLICIT_EULER, INTEGRATIONSCHEME_IMPLICIT_EULER, INTEGRATIONSCHEME_LINEAR_IMPLICIT_EULER,
  INTEGRATIONSCHEME_RUNGE_KUTTA_4, INTEGRATIONSCHEME_LINEAR_RUNGE_KUTTA_4
}
 The diverse numerical integration scheme supported Each Ode Solver should have its own entry in this enum. More...
 
enum  ShapeDirection { SHAPE_DIRECTION_AXIS_X = 0, SHAPE_DIRECTION_AXIS_Y = 1, SHAPE_DIRECTION_AXIS_Z = 2 }
 Type defining the shape direction for certain templatized shape (i.e. More...
 
enum  ShapeType {
  SHAPE_TYPE_NONE = -1, SHAPE_TYPE_BOX, SHAPE_TYPE_CAPSULE, SHAPE_TYPE_CYLINDER,
  SHAPE_TYPE_DOUBLESIDEDPLANE, SHAPE_TYPE_MESH, SHAPE_TYPE_OCTREE, SHAPE_TYPE_PLANE,
  SHAPE_TYPE_SPHERE, SHAPE_TYPE_SURFACEMESH, SHAPE_TYPE_COUNT
}
 Fixed List of enums for the available Shape types, do not explicitly assign values, ShapeCount is used to determine the number of actual shape types. More...
 

Functions

template<class Scalar , int Dim>
bool doAabbIntersect (const Eigen::AlignedBox< Scalar, Dim > &aabb0, const Eigen::AlignedBox< Scalar, Dim > &aabb1, double tolerance)
 Determine whether two AABBs have an intersection with each other, for the calculation see http://www.gamasutra.com/view/feature/131790/simple_intersection_tests_for_games.php?page=3. More...
 
template<class Scalar , int Dim>
bool doAabbIntersect (const Eigen::AlignedBox< Scalar, Dim > &a, const Eigen::AlignedBox< Scalar, Dim > &b)
 Determine whether two AABBs overlap, using a minimal set of eigen calls, does not take a tolerance. More...
 
template<class Scalar , int Dim, int MType>
Eigen::AlignedBox< Scalar, Dim > makeAabb (const Eigen::Matrix< Scalar, Dim, 1, MType > &vector0, const Eigen::Matrix< Scalar, Dim, 1, MType > &vector1, const Eigen::Matrix< Scalar, Dim, 1, MType > &vector2)
 Convenience function for creating a bounding box from three vertices (e.g. More...
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::BoxShape, BoxShape)
 
 SURGSIM_STATIC_REGISTRATION (BoxShape)
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::CapsuleShape, CapsuleShape)
 
 SURGSIM_STATIC_REGISTRATION (CapsuleShape)
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::CylinderShape, CylinderShape)
 
 SURGSIM_STATIC_REGISTRATION (CylinderShape)
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::DoubleSidedPlaneShape, DoubleSidedPlaneShape)
 
 SURGSIM_STATIC_REGISTRATION (DoubleSidedPlaneShape)
 
template<class T , int MOpt>
bool barycentricCoordinates (const Eigen::Matrix< T, 3, 1, MOpt > &pt, const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2, const Eigen::Matrix< T, 3, 1, MOpt > &tn, Eigen::Matrix< T, 3, 1, MOpt > *coordinates)
 Calculate the barycentric coordinates of a point with respect to a triangle. More...
 
template<class T , int MOpt>
bool barycentricCoordinates (const Eigen::Matrix< T, 3, 1, MOpt > &pt, const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2, Eigen::Matrix< T, 3, 1, MOpt > *coordinates)
 Calculate the barycentric coordinates of a point with respect to a triangle. More...
 
template<class T , int MOpt>
bool isPointInsideTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &pt, const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2, const Eigen::Matrix< T, 3, 1, MOpt > &tn)
 Check if a point is inside a triangle. More...
 
template<class T , int MOpt>
bool isPointInsideTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &pt, const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2)
 Check if a point is inside a triangle. More...
 
template<class T , int MOpt>
bool isCoplanar (const Eigen::Matrix< T, 3, 1, MOpt > &a, const Eigen::Matrix< T, 3, 1, MOpt > &b, const Eigen::Matrix< T, 3, 1, MOpt > &c, const Eigen::Matrix< T, 3, 1, MOpt > &d)
 Check whether the points are coplanar. More...
 
template<class T , int MOpt>
distancePointLine (const Eigen::Matrix< T, 3, 1, MOpt > &pt, const Eigen::Matrix< T, 3, 1, MOpt > &v0, const Eigen::Matrix< T, 3, 1, MOpt > &v1, Eigen::Matrix< T, 3, 1, MOpt > *result)
 Calculate the normal distance between a point and a line. More...
 
template<class T , int MOpt>
distancePointSegment (const Eigen::Matrix< T, 3, 1, MOpt > &pt, const Eigen::Matrix< T, 3, 1, MOpt > &sv0, const Eigen::Matrix< T, 3, 1, MOpt > &sv1, Eigen::Matrix< T, 3, 1, MOpt > *result)
 Point segment distance, if the projection of the closest point is not within the segments, the closest segment point is used for the distance calculation. More...
 
template<class T , int MOpt>
distanceLineLine (const Eigen::Matrix< T, 3, 1, MOpt > &l0v0, const Eigen::Matrix< T, 3, 1, MOpt > &l0v1, const Eigen::Matrix< T, 3, 1, MOpt > &l1v0, const Eigen::Matrix< T, 3, 1, MOpt > &l1v1, Eigen::Matrix< T, 3, 1, MOpt > *pt0, Eigen::Matrix< T, 3, 1, MOpt > *pt1)
 Determine the distance between two lines. More...
 
template<class T , int MOpt>
distanceSegmentSegment (const Eigen::Matrix< T, 3, 1, MOpt > &s0v0, const Eigen::Matrix< T, 3, 1, MOpt > &s0v1, const Eigen::Matrix< T, 3, 1, MOpt > &s1v0, const Eigen::Matrix< T, 3, 1, MOpt > &s1v1, Eigen::Matrix< T, 3, 1, MOpt > *pt0, Eigen::Matrix< T, 3, 1, MOpt > *pt1, T *s0t=nullptr, T *s1t=nullptr)
 Distance between two segments, if the project of the closest point is not on the opposing segment, the segment endpoints will be used for the distance calculation. More...
 
template<class T , int MOpt>
distancePointTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &pt, const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2, Eigen::Matrix< T, 3, 1, MOpt > *result)
 Calculate the normal distance of a point from a triangle, the resulting point will be on the edge of the triangle if the projection of the point is not inside the triangle. More...
 
template<class T , int MOpt>
bool doesCollideSegmentTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &sv0, const Eigen::Matrix< T, 3, 1, MOpt > &sv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2, const Eigen::Matrix< T, 3, 1, MOpt > &tn, Eigen::Matrix< T, 3, 1, MOpt > *result)
 Calculate the intersection of a line segment with a triangle See http://geomalgorithms.com/a06-_intersect-2.html#intersect_RayTriangle for the algorithm. More...
 
template<class T , int MOpt>
distancePointPlane (const Eigen::Matrix< T, 3, 1, MOpt > &pt, const Eigen::Matrix< T, 3, 1, MOpt > &n, T d, Eigen::Matrix< T, 3, 1, MOpt > *result)
 Calculate the distance of a point to a plane. More...
 
template<class T , int MOpt>
distanceSegmentPlane (const Eigen::Matrix< T, 3, 1, MOpt > &sv0, const Eigen::Matrix< T, 3, 1, MOpt > &sv1, const Eigen::Matrix< T, 3, 1, MOpt > &n, T d, Eigen::Matrix< T, 3, 1, MOpt > *closestPointSegment, Eigen::Matrix< T, 3, 1, MOpt > *planeIntersectionPoint)
 Calculate the distance between a segment and a plane. More...
 
template<class T , int MOpt>
distanceTrianglePlane (const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2, const Eigen::Matrix< T, 3, 1, MOpt > &n, T d, Eigen::Matrix< T, 3, 1, MOpt > *closestPointTriangle, Eigen::Matrix< T, 3, 1, MOpt > *planeProjectionPoint)
 Calculate the distance of a triangle to a plane. More...
 
template<class T , int MOpt>
bool doesIntersectPlanePlane (const Eigen::Matrix< T, 3, 1, MOpt > &pn0, T pd0, const Eigen::Matrix< T, 3, 1, MOpt > &pn1, T pd1, Eigen::Matrix< T, 3, 1, MOpt > *pt0, Eigen::Matrix< T, 3, 1, MOpt > *pt1)
 Test if two planes are intersecting, if yes also calculate the intersection line. More...
 
template<class T , int MOpt>
distanceSegmentTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &sv0, const Eigen::Matrix< T, 3, 1, MOpt > &sv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2, Eigen::Matrix< T, 3, 1, MOpt > *segmentPoint, Eigen::Matrix< T, 3, 1, MOpt > *trianglePoint)
 Calculate the distance of a line segment to a triangle. More...
 
template<class T , int MOpt>
distanceSegmentTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &sv0, const Eigen::Matrix< T, 3, 1, MOpt > &sv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv0, const Eigen::Matrix< T, 3, 1, MOpt > &tv1, const Eigen::Matrix< T, 3, 1, MOpt > &tv2, const Eigen::Matrix< T, 3, 1, MOpt > &normal, Eigen::Matrix< T, 3, 1, MOpt > *segmentPoint, Eigen::Matrix< T, 3, 1, MOpt > *trianglePoint)
 Calculate the distance of a line segment to a triangle. More...
 
template<class T , int MOpt>
distanceTriangleTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &t0v0, const Eigen::Matrix< T, 3, 1, MOpt > &t0v1, const Eigen::Matrix< T, 3, 1, MOpt > &t0v2, const Eigen::Matrix< T, 3, 1, MOpt > &t1v0, const Eigen::Matrix< T, 3, 1, MOpt > &t1v1, const Eigen::Matrix< T, 3, 1, MOpt > &t1v2, Eigen::Matrix< T, 3, 1, MOpt > *closestPoint0, Eigen::Matrix< T, 3, 1, MOpt > *closestPoint1)
 Calculate the distance between two triangles. More...
 
template<class T , int MOpt>
void intersectionsSegmentBox (const Eigen::Matrix< T, 3, 1, MOpt > &sv0, const Eigen::Matrix< T, 3, 1, MOpt > &sv1, const Eigen::AlignedBox< T, 3 > &box, std::vector< Eigen::Matrix< T, 3, 1, MOpt > > *intersections)
 Calculate the intersections between a line segment and an axis aligned box. More...
 
template<class T , int MOpt>
bool doesIntersectBoxCapsule (const Eigen::Matrix< T, 3, 1, MOpt > &capsuleBottom, const Eigen::Matrix< T, 3, 1, MOpt > &capsuleTop, const T capsuleRadius, const Eigen::AlignedBox< T, 3 > &box)
 Test if an axis aligned box intersects with a capsule. More...
 
template<class T , int MOpt>
bool doesIntersectTriangleTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &t0v0, const Eigen::Matrix< T, 3, 1, MOpt > &t0v1, const Eigen::Matrix< T, 3, 1, MOpt > &t0v2, const Eigen::Matrix< T, 3, 1, MOpt > &t1v0, const Eigen::Matrix< T, 3, 1, MOpt > &t1v1, const Eigen::Matrix< T, 3, 1, MOpt > &t1v2, const Eigen::Matrix< T, 3, 1, MOpt > &t0n, const Eigen::Matrix< T, 3, 1, MOpt > &t1n)
 Check if the two triangles intersect using separating axis test. More...
 
template<class T , int MOpt>
bool doesIntersectTriangleTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &t0v0, const Eigen::Matrix< T, 3, 1, MOpt > &t0v1, const Eigen::Matrix< T, 3, 1, MOpt > &t0v2, const Eigen::Matrix< T, 3, 1, MOpt > &t1v0, const Eigen::Matrix< T, 3, 1, MOpt > &t1v1, const Eigen::Matrix< T, 3, 1, MOpt > &t1v2)
 Check if the two triangles intersect using separating axis test. More...
 
template<class T , int MOpt>
bool calculateContactTriangleTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &t0v0, const Eigen::Matrix< T, 3, 1, MOpt > &t0v1, const Eigen::Matrix< T, 3, 1, MOpt > &t0v2, const Eigen::Matrix< T, 3, 1, MOpt > &t1v0, const Eigen::Matrix< T, 3, 1, MOpt > &t1v1, const Eigen::Matrix< T, 3, 1, MOpt > &t1v2, const Eigen::Matrix< T, 3, 1, MOpt > &t0n, const Eigen::Matrix< T, 3, 1, MOpt > &t1n, T *penetrationDepth, Eigen::Matrix< T, 3, 1, MOpt > *penetrationPoint0, Eigen::Matrix< T, 3, 1, MOpt > *penetrationPoint1, Eigen::Matrix< T, 3, 1, MOpt > *contactNormal)
 Calculate the contact between two triangles. More...
 
template<class T , int MOpt>
bool calculateContactTriangleTriangle (const Eigen::Matrix< T, 3, 1, MOpt > &t0v0, const Eigen::Matrix< T, 3, 1, MOpt > &t0v1, const Eigen::Matrix< T, 3, 1, MOpt > &t0v2, const Eigen::Matrix< T, 3, 1, MOpt > &t1v0, const Eigen::Matrix< T, 3, 1, MOpt > &t1v1, const Eigen::Matrix< T, 3, 1, MOpt > &t1v2, T *penetrationDepth, Eigen::Matrix< T, 3, 1, MOpt > *penetrationPoint0, Eigen::Matrix< T, 3, 1, MOpt > *penetrationPoint1, Eigen::Matrix< T, 3, 1, MOpt > *contactNormal)
 Calculate the contact between two triangles. More...
 
template<typename T , int VOpt>
Eigen::Matrix< T, 3, 3 > makeRotationMatrix (const T &angle, const Eigen::Matrix< T, 3, 1, VOpt > &axis)
 Create a rotation matrix corresponding to the specified angle (in radians) and axis. More...
 
template<typename T , int VOpt>
Eigen::Matrix< T, 3, 3 > makeSkewSymmetricMatrix (const Eigen::Matrix< T, 3, 1, VOpt > &vector)
 Create a skew-symmetric matrix corresponding to the specified vector. More...
 
template<typename T , int MOpt>
Eigen::Matrix< T, 3, 1 > skew (const Eigen::Matrix< T, 3, 3, MOpt > &matrix)
 Extract the unique vector from the skew-symmetric part of a given matrix. More...
 
template<typename T , int MOpt, int VOpt>
void computeAngleAndAxis (const Eigen::Matrix< T, 3, 3, MOpt > &matrix, T *angle, Eigen::Matrix< T, 3, 1, VOpt > *axis)
 Get the angle (in radians) and axis corresponding to a rotation matrix. More...
 
template<typename T , int MOpt>
computeAngle (const Eigen::Matrix< T, 3, 3, MOpt > &matrix)
 Get the angle corresponding to a quaternion's rotation, in radians. More...
 
template<class Matrix , class SubMatrix >
void addSubMatrix (const SubMatrix &subMatrix, size_t blockIdRow, size_t blockIdCol, size_t blockSizeRow, size_t blockSizeCol, Matrix *matrix)
 Helper method to add a sub-matrix into a matrix, for the sake of clarity. More...
 
template<class Matrix , class SubMatrix >
void addSubMatrix (const SubMatrix &subMatrix, const std::vector< size_t > blockIds, size_t blockSize, Matrix *matrix)
 Helper method to add a sub-matrix made of squared-blocks into a matrix, for the sake of clarity. More...
 
template<class Matrix , class SubMatrix >
void setSubMatrix (const SubMatrix &subMatrix, size_t blockIdRow, size_t blockIdCol, size_t blockSizeRow, size_t blockSizeCol, Matrix *matrix)
 Helper method to set a sub-matrix into a matrix, for the sake of clarity. More...
 
template<class Matrix >
Eigen::Block< MatrixgetSubMatrix (Matrix &matrix, size_t blockIdRow, size_t blockIdCol, size_t blockSizeRow, size_t blockSizeCol)
 Helper method to access a sub-matrix from a matrix, for the sake of clarity. More...
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::MeshShape, MeshShape)
 
 SURGSIM_STATIC_REGISTRATION (MeshShape)
 
std::string getMlcpConstraintTypeName (MlcpConstraintType constraintType)
 
MlcpConstraintType getMlcpConstraintTypeValue (const std::string &typeName)
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::OctreeShape, OctreeShape)
 
 SURGSIM_STATIC_REGISTRATION (OctreeShape)
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::PlaneShape, PlaneShape)
 
 SURGSIM_STATIC_REGISTRATION (PlaneShape)
 
template<typename T , int VOpt>
Eigen::Quaternion< T > makeRotationQuaternion (const T &angle, const Eigen::Matrix< T, 3, 1, VOpt > &axis)
 Create a quaternion rotation corresponding to the specified angle (in radians) and axis. More...
 
template<typename T , int QOpt>
Eigen::Quaternion< T, QOpt > negate (const Eigen::Quaternion< T, QOpt > &q)
 Quaternion negation (i.e. More...
 
template<typename T , int QOpt, int VOpt>
void computeAngleAndAxis (const Eigen::Quaternion< T, QOpt > &quaternion, T *angle, Eigen::Matrix< T, 3, 1, VOpt > *axis)
 Get the angle (in radians) and axis corresponding to a quaternion's rotation. More...
 
template<typename T , int QOpt>
computeAngle (const Eigen::Quaternion< T, QOpt > &quaternion)
 Get the angle corresponding to a quaternion's rotation, in radians. More...
 
template<typename T , int TOpt, int VOpt>
void computeRotationVector (const Eigen::Transform< T, 3, Eigen::Isometry, TOpt > &end, const Eigen::Transform< T, 3, Eigen::Isometry, TOpt > &start, Eigen::Matrix< T, 3, 1, VOpt > *rotationVector)
 Get the vector corresponding to the rotation between transforms. More...
 
template<typename T , int QOpt>
Eigen::Quaternion< T, QOpt > interpolate (const Eigen::Quaternion< T, QOpt > &q0, const Eigen::Quaternion< T, QOpt > &q1, T t)
 Interpolate (slerp) between 2 quaternions. More...
 
template<typename M , typename V >
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. More...
 
template<typename Q , typename V >
Eigen::Transform< typename
Q::Scalar, 3, Eigen::Isometry > 
makeRigidTransform (const Eigen::QuaternionBase< Q > &rotation, const Eigen::MatrixBase< V > &translation)
 Create a rigid transform using the specified rotation quaternion and translation. More...
 
template<typename T , int VOpt>
Eigen::Transform< T,
3, Eigen::Isometry > 
makeRigidTransform (const Eigen::Matrix< T, 3, 1, VOpt > &position, const Eigen::Matrix< T, 3, 1, VOpt > &center, const Eigen::Matrix< T, 3, 1, VOpt > &up)
 Make a rigid transform from a eye point a center view point and an up direction, does not check whether up is colinear with eye-center The original formula can be found at http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml. More...
 
template<typename V >
Eigen::Transform< typename
V::Scalar,
V::SizeAtCompileTime,
Eigen::Isometry > 
makeRigidTranslation (const Eigen::MatrixBase< V > &translation)
 Create a rigid transform using the identity rotation and the specified translation. More...
 
template<typename T , int TOpt>
Eigen::Transform< T,
3, Eigen::Isometry > 
interpolate (const Eigen::Transform< T, 3, Eigen::Isometry, TOpt > &t0, const Eigen::Transform< T, 3, Eigen::Isometry, TOpt > &t1, T t)
 Interpolate (slerp) between 2 rigid transformations. More...
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::SphereShape, SphereShape)
 
 SURGSIM_STATIC_REGISTRATION (SphereShape)
 
 SURGSIM_REGISTER (SurgSim::Math::Shape, SurgSim::Math::SurfaceMeshShape, SurfaceMeshShape)
 
 SURGSIM_STATIC_REGISTRATION (SurfaceMeshShape)
 
template<class T >
void edgeIntersection (T dStart, T dEnd, T pvStart, T pvEnd, T *parametricIntersection, size_t *parametricIntersectionIndex)
 Two ends of the triangle edge are given in terms of the following vertex properties. More...
 
bool isValid (float value)
 Check if a float value is valid. More...
 
bool isValid (double value)
 Check if a double value is valid. More...
 
template<typename T >
bool isValid (const Eigen::DenseBase< T > &value)
 Check if a matrix or a vector is valid. More...
 
template<typename T >
bool isValid (const Eigen::QuaternionBase< T > &value)
 Check if a quaternion is valid. More...
 
template<typename T >
bool isValid (const Eigen::AngleAxis< T > &value)
 Check if an angle/axis 3D rotation is valid. More...
 
template<typename T >
bool isValid (const Eigen::Rotation2D< T > &value)
 Check if a 2D rotation is valid. More...
 
template<typename T , int D, int M, int O>
bool isValid (const Eigen::Transform< T, D, M, O > &value)
 Check if a transform is valid. More...
 
bool isSubnormal (float value)
 Check if a float value is subnormal. More...
 
bool isSubnormal (double value)
 Check if a double value is subnormal. More...
 
template<typename T >
bool isSubnormal (const Eigen::DenseBase< T > &value)
 Check if a matrix or a vector contains any subnormal floating-point values. More...
 
template<typename T >
bool isSubnormal (const Eigen::QuaternionBase< T > &value)
 Check if a quaternion contains any subnormal floating-point values. More...
 
template<typename T >
bool isSubnormal (const Eigen::AngleAxis< T > &value)
 Check if an angle/axis 3D rotation contains any subnormal floating-point values. More...
 
template<typename T >
bool isSubnormal (const Eigen::Rotation2D< T > &value)
 Check if a 2D rotation is described by an angle that is subnormal. More...
 
template<typename T , int D, int M, int O>
bool isSubnormal (const Eigen::Transform< T, D, M, O > &value)
 Check if a transform contains any subnormal floating-point values. More...
 
bool setSubnormalToZero (float *value)
 If the float value is subnormal, set it to zero. More...
 
bool setSubnormalToZero (double *value)
 If the double value is subnormal, set it to zero. More...
 
template<typename T >
bool setSubnormalToZero (Eigen::DenseBase< T > *value)
 Set all subnormal values in a matrix or a vector to zero. More...
 
template<typename T >
bool setSubnormalToZero (Eigen::QuaternionBase< T > *value)
 Set all subnormal values in a quaternion to zero. More...
 
template<typename T >
bool setSubnormalToZero (Eigen::AngleAxis< T > *value)
 Set all subnormal values in an angle/axis 3D rotation to zero. More...
 
template<typename T >
bool setSubnormalToZero (Eigen::Rotation2D< T > *value)
 If the angle of a 2D rotation is subnormal, set it to zero. More...
 
template<typename T , int D, int M, int O>
bool setSubnormalToZero (Eigen::Transform< T, D, M, O > *value)
 Set all subnormal values in a transform to zero. More...
 
template<class Vector , class SubVector >
void addSubVector (const SubVector &subVector, size_t blockId, size_t blockSize, Vector *vector)
 Helper method to add a sub-vector into a vector, for the sake of clarity. More...
 
template<class Vector , class SubVector >
void addSubVector (const SubVector &subVector, const std::vector< size_t > blockIds, size_t blockSize, Vector *vector)
 Helper method to add a sub-vector per block into a vector, for the sake of clarity. More...
 
template<class Vector , class SubVector >
void setSubVector (const SubVector &subVector, size_t blockId, size_t blockSize, Vector *vector)
 Helper method to set a sub-vector into a vector, for the sake of clarity. More...
 
template<class Vector >
Eigen::VectorBlock< VectorgetSubVector (Vector &vector, size_t blockId, size_t blockSize)
 Helper method to access a sub-vector from a vector, for the sake of clarity. More...
 
template<class Vector , class SubVector >
void getSubVector (const Vector &vector, const std::vector< size_t > blockIds, size_t blockSize, SubVector *subVector)
 Helper method to get a sub-vector per block from a vector, for the sake of clarity. More...
 
template<typename T , int size, int TOpt>
Eigen::Matrix< T, size, 1, TOpt > interpolate (const Eigen::Matrix< T, size, 1, TOpt > &previous, const Eigen::Matrix< T, size, 1, TOpt > &next, T t)
 Interpolate (slerp) between 2 vectors. More...
 
template<class T , int VOpt>
bool buildOrthonormalBasis (Eigen::Matrix< T, 3, 1, VOpt > *i, Eigen::Matrix< T, 3, 1, VOpt > *j, Eigen::Matrix< T, 3, 1, VOpt > *k)
 Helper method to construct an orthonormal basis (i, j, k) given the 1st vector direction. More...
 

Variables

std::array
< gaussQuadraturePoint, 1 > 
gaussQuadrature1Point
 1-point Gauss-Legendre quadrature {<x_1, w_1>} More...
 
std::array
< gaussQuadraturePoint, 2 > 
gaussQuadrature2Points
 2-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>} More...
 
std::array
< gaussQuadraturePoint, 3 > 
gaussQuadrature3Points
 3-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>, <x_3, w_3>} More...
 
std::array
< gaussQuadraturePoint, 4 > 
gaussQuadrature4Points
 4-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>, <x_3, w_3>, <x_4, w_4>} More...
 
std::array
< gaussQuadraturePoint, 5 > 
gaussQuadrature5Points
 5-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>, <x_3, w_3>, <x_4, w_4>, <x_5, w_5>} More...
 
std::array
< gaussQuadraturePoint, 100 > 
gaussQuadrature100Points
 100-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>, <x_3, w_3>, ..., <x_100, w_100>} More...
 
const std::unordered_map
< IntegrationScheme,
std::string, std::hash< int > > 
IntegrationSchemeNames
 

Typedef Documentation

typedef Eigen::AlignedBox<double, 3> SurgSim::Math::Aabbd

Wrapper around the Eigen type.

typedef Eigen::AlignedBox<float, 3> SurgSim::Math::Aabbf

Wrapper around the Eigen type.

typedef Eigen::DiagonalMatrix<double, Eigen::Dynamic> SurgSim::Math::DiagonalMatrix

A dynamic size diagonal matrix.

typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> SurgSim::Math::Matrix

A dynamic size matrix.

typedef Eigen::Matrix<double, 2, 2, Eigen::RowMajor> SurgSim::Math::Matrix22d

A 2x2 matrix of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<float, 2, 2, Eigen::RowMajor> SurgSim::Math::Matrix22f

A 2x2 matrix of floats.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<double, 3, 3, Eigen::RowMajor> SurgSim::Math::Matrix33d

A 3x3 matrix of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<float, 3, 3, Eigen::RowMajor> SurgSim::Math::Matrix33f

A 3x3 matrix of floats.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<double, 4, 4, Eigen::RowMajor> SurgSim::Math::Matrix44d

A 4x4 matrix of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<float, 4, 4, Eigen::RowMajor> SurgSim::Math::Matrix44f

A 4x4 matrix of floats.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<double, 6, 6, Eigen::RowMajor> SurgSim::Math::Matrix66d

A 6x6 matrix of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Quaternion<double> SurgSim::Math::Quaterniond

A quaternion of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Quaternion<float> SurgSim::Math::Quaternionf

A quaternion of floats.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Transform<double, 2, Eigen::Isometry> SurgSim::Math::RigidTransform2d

A 2D rigid (isometric) transform, represented as doubles.

This type (and any struct that contain it) can be safely allocated via new.

typedef Eigen::Transform<float, 2, Eigen::Isometry> SurgSim::Math::RigidTransform2f

A 2D rigid (isometric) transform, represented as floats.

This type (and any struct that contain it) can be safely allocated via new.

typedef Eigen::Transform<double, 3, Eigen::Isometry> SurgSim::Math::RigidTransform3d

A 3D rigid (isometric) transform, represented as doubles.

This type (and any struct that contain it) can be safely allocated via new.

typedef Eigen::Transform<float, 3, Eigen::Isometry> SurgSim::Math::RigidTransform3f

A 3D rigid (isometric) transform, represented as floats.

This type (and any struct that contain it) can be safely allocated via new.

typedef Eigen::Matrix<double, Eigen::Dynamic, 1> SurgSim::Math::Vector

A dynamic size column vector.

typedef Eigen::Matrix<double, 2, 1> SurgSim::Math::Vector2d

A 2D vector of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<float, 2, 1> SurgSim::Math::Vector2f

A 2D vector of floats.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<double, 3, 1> SurgSim::Math::Vector3d

A 3D vector of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<float, 3, 1> SurgSim::Math::Vector3f

A 3D vector of floats.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<double, 4, 1> SurgSim::Math::Vector4d

A 4D vector of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<float, 4, 1> SurgSim::Math::Vector4f

A 4D vector of floats.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<double, 6, 1> SurgSim::Math::Vector6d

A 6D matrix of doubles.

This type (and any structs that contain it) can be safely allocated via new.

typedef Eigen::Matrix<float, 6, 1> SurgSim::Math::Vector6f

A 6D vector of floats.

This type (and any structs that contain it) can be safely allocated via new.

Enumeration Type Documentation

The diverse numerical integration scheme supported Each Ode Solver should have its own entry in this enum.

Enumerator
INTEGRATIONSCHEME_STATIC 
INTEGRATIONSCHEME_LINEAR_STATIC 
INTEGRATIONSCHEME_EXPLICIT_EULER 
INTEGRATIONSCHEME_LINEAR_EXPLICIT_EULER 
INTEGRATIONSCHEME_MODIFIED_EXPLICIT_EULER 
INTEGRATIONSCHEME_LINEAR_MODIFIED_EXPLICIT_EULER 
INTEGRATIONSCHEME_IMPLICIT_EULER 
INTEGRATIONSCHEME_LINEAR_IMPLICIT_EULER 
INTEGRATIONSCHEME_RUNGE_KUTTA_4 
INTEGRATIONSCHEME_LINEAR_RUNGE_KUTTA_4 
Enumerator
MLCP_INVALID_CONSTRAINT 
MLCP_BILATERAL_1D_CONSTRAINT 
MLCP_BILATERAL_2D_CONSTRAINT 
MLCP_BILATERAL_3D_CONSTRAINT 
MLCP_UNILATERAL_3D_FRICTIONLESS_CONSTRAINT 
MLCP_UNILATERAL_3D_FRICTIONAL_CONSTRAINT 
MLCP_BILATERAL_FRICTIONLESS_SLIDING_CONSTRAINT 
MLCP_BILATERAL_FRICTIONAL_SLIDING_CONSTRAINT 
MLCP_NUM_CONSTRAINT_TYPES 

Type defining the shape direction for certain templatized shape (i.e.

CylinderShape and CapsuleShape)

Enumerator
SHAPE_DIRECTION_AXIS_X 
SHAPE_DIRECTION_AXIS_Y 
SHAPE_DIRECTION_AXIS_Z 

Fixed List of enums for the available Shape types, do not explicitly assign values, ShapeCount is used to determine the number of actual shape types.

Enumerator
SHAPE_TYPE_NONE 
SHAPE_TYPE_BOX 
SHAPE_TYPE_CAPSULE 
SHAPE_TYPE_CYLINDER 
SHAPE_TYPE_DOUBLESIDEDPLANE 
SHAPE_TYPE_MESH 
SHAPE_TYPE_OCTREE 
SHAPE_TYPE_PLANE 
SHAPE_TYPE_SPHERE 
SHAPE_TYPE_SURFACEMESH 
SHAPE_TYPE_COUNT 

Function Documentation

template<class Matrix , class SubMatrix >
void SurgSim::Math::addSubMatrix ( const SubMatrix &  subMatrix,
size_t  blockIdRow,
size_t  blockIdCol,
size_t  blockSizeRow,
size_t  blockSizeCol,
Matrix *  matrix 
)

Helper method to add a sub-matrix into a matrix, for the sake of clarity.

Template Parameters
MatrixThe matrix type
SubMatrixThe sub-matrix type
Parameters
subMatrixThe sub-matrix
blockIdRow,blockIdColThe block indices in matrix
blockSizeRow,blockSizeColThe block size (size of the sub-matrix)
[out]matrixThe matrix to add the sub-matrix into
template<class Matrix , class SubMatrix >
void SurgSim::Math::addSubMatrix ( const SubMatrix &  subMatrix,
const std::vector< size_t >  blockIds,
size_t  blockSize,
Matrix *  matrix 
)

Helper method to add a sub-matrix made of squared-blocks into a matrix, for the sake of clarity.

Template Parameters
MatrixThe matrix type
SubMatrixThe sub-matrix type
Parameters
subMatrixThe sub-matrix (containing all the squared-blocks)
blockIdsVector of block indices (for accessing matrix) corresponding to the blocks in sub-matrix
blockSizeThe blocks size
[out]matrixThe matrix to add the sub-matrix blocks into
template<class Vector , class SubVector >
void SurgSim::Math::addSubVector ( const SubVector &  subVector,
size_t  blockId,
size_t  blockSize,
Vector *  vector 
)

Helper method to add a sub-vector into a vector, for the sake of clarity.

Template Parameters
VectorThe vector type
SubVectorThe sub-vector type
Parameters
subVectorThe sub-vector
blockIdThe block index in vector
blockSizeThe block size
[out]vectorThe vector to add the sub-vector into
template<class Vector , class SubVector >
void SurgSim::Math::addSubVector ( const SubVector &  subVector,
const std::vector< size_t >  blockIds,
size_t  blockSize,
Vector *  vector 
)

Helper method to add a sub-vector per block into a vector, for the sake of clarity.

Template Parameters
VectorThe vector type
SubVectorThe sub-vector type
Parameters
subVectorThe sub-vector (containing all the blocks)
blockIdsVector of block indices (for accessing vector) corresponding to the blocks in sub-vector
blockSizeThe block size
[out]vectorThe vector to add the sub-vector blocks into
template<class T , int MOpt>
bool SurgSim::Math::barycentricCoordinates ( const Eigen::Matrix< T, 3, 1, MOpt > &  pt,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2,
const Eigen::Matrix< T, 3, 1, MOpt > &  tn,
Eigen::Matrix< T, 3, 1, MOpt > *  coordinates 
)
inline

Calculate the barycentric coordinates of a point with respect to a triangle.

Precondition
The normal must be unit length
The triangle vertices must be in counter clockwise order in respect to the normal
Template Parameters
TFloating point type of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
ptVertex of the point.
tv0,tv1,tv2Vertices of the triangle in counter clockwise order in respect to the normal.
tnNormal of the triangle (yes must be of norm 1 and a,b,c CCW).
[out]coordinatesBarycentric coordinates.
Returns
bool true on success, false if two or more if the triangle is considered degenerate
template<class T , int MOpt>
bool SurgSim::Math::barycentricCoordinates ( const Eigen::Matrix< T, 3, 1, MOpt > &  pt,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2,
Eigen::Matrix< T, 3, 1, MOpt > *  coordinates 
)
inline

Calculate the barycentric coordinates of a point with respect to a triangle.

Please note that each time you use this call the normal of the triangle will be calculated, if you convert more than one coordinate against this triangle, precalculate the normal and use the other version of this function

Template Parameters
TFloating point type of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
ptVertex of the point.
tv0,tv1,tv2Vertices of the triangle.
[out]coordinatesThe Barycentric coordinates.
Returns
bool true on success, false if two or more if the triangle is considered degenerate
template<class T , int VOpt>
bool SurgSim::Math::buildOrthonormalBasis ( Eigen::Matrix< T, 3, 1, VOpt > *  i,
Eigen::Matrix< T, 3, 1, VOpt > *  j,
Eigen::Matrix< T, 3, 1, VOpt > *  k 
)

Helper method to construct an orthonormal basis (i, j, k) given the 1st vector direction.

Template Parameters
Tthe numeric data type used for the vector argument. Can usually be deduced.
VOptthe option flags (alignment etc.) used for the vector argument. Can be deduced.
Parameters
[in,out]iShould provide the 1st direction on input. The 1st vector of the basis (i, j, k) on output.
[out]j,kThe 2nd and 3rd orthonormal vectors of the basis (i, j, k)
Returns
True if (i, j, k) has been built successfully, False if 'i' is a (or close to a) null vector
Note
If any of the parameter is a nullptr, an exception will be raised
template<class T , int MOpt>
bool SurgSim::Math::calculateContactTriangleTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  t0v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v2,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v2,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0n,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1n,
T *  penetrationDepth,
Eigen::Matrix< T, 3, 1, MOpt > *  penetrationPoint0,
Eigen::Matrix< T, 3, 1, MOpt > *  penetrationPoint1,
Eigen::Matrix< T, 3, 1, MOpt > *  contactNormal 
)
inline

Calculate the contact between two triangles.

Algorithm presented in https://docs.google.com/a/simquest.com/document/d/11ajMD7QoTVelT2_szGPpeUEY0wHKKxW1TOgMe8k5Fsc/pub. If the triangle are known to intersect, the deepest penetration of the triangles into each other is calculated. The triangle which penetrates less into the other triangle is chosen as contact.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
t0v0,t0v1,t0v2Vertices of the first triangle.
t1v0,t1v1,t1v2Vertices of the second triangle.
t0nUnit length normal of the first triangle, should be normalized.
t1nUnit length normal of the second triangle, should be normalized.
[out]penetrationDepthThe depth of penetration.
[out]penetrationPoint0The contact point on triangle0 (t0v0,t0v1,t0v2).
[out]penetrationPoint1The contact point on triangle1 (t1v0,t1v1,t1v2).
[out]contactNormalThe contact normal that points from triangle1 to triangle0.
Returns
True, if intersection is detected.
Note
The [out] params are not modified if there is no intersection.
If penetrationPoint0 is moved by (contactNormal*penetrationDepth*0.5) and penetrationPoint1 is moved by -(contactNormal*penetrationDepth*0.5), the triangles will no longer be intersecting.
template<class T , int MOpt>
bool SurgSim::Math::calculateContactTriangleTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  t0v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v2,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v2,
T *  penetrationDepth,
Eigen::Matrix< T, 3, 1, MOpt > *  penetrationPoint0,
Eigen::Matrix< T, 3, 1, MOpt > *  penetrationPoint1,
Eigen::Matrix< T, 3, 1, MOpt > *  contactNormal 
)
inline

Calculate the contact between two triangles.

Algorithm presented in https://docs.google.com/a/simquest.com/document/d/11ajMD7QoTVelT2_szGPpeUEY0wHKKxW1TOgMe8k5Fsc/pub. If the triangle are known to intersect, the deepest penetration of the triangles into each other is calculated. The triangle which penetrates less into the other triangle is chosen as contact.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
t0v0,t0v1,t0v2Vertices of the first triangle, should be normalized.
t1v0,t1v1,t1v2Vertices of the second triangle, should be normalized.
[out]penetrationDepthThe depth of penetration.
[out]penetrationPoint0The contact point on triangle0 (t0v0,t0v1,t0v2).
[out]penetrationPoint1The contact point on triangle1 (t1v0,t1v1,t1v2).
[out]contactNormalThe contact normal that points from triangle1 to triangle0.
Returns
True, if intersection is detected.
Note
The [out] params are not modified if there is no intersection.
If penetrationPoint0 is moved by (contactNormal*penetrationDepth*0.5) and penetrationPoint1 is moved by -(contactNormal*penetrationDepth*0.5), the triangles will no longer be intersecting.
template<typename T , int QOpt>
T SurgSim::Math::computeAngle ( const Eigen::Quaternion< T, QOpt > &  quaternion)
inline

Get the angle corresponding to a quaternion's rotation, in radians.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
QOptthe option flags (alignment etc.) used for the quaternion argument. Can be deduced.
Parameters
quaternionthe rotation quaternion to inspect.
Returns
the angle of the rotation within [0 +pi], in radians.
template<typename T , int MOpt>
T SurgSim::Math::computeAngle ( const Eigen::Matrix< T, 3, 3, MOpt > &  matrix)
inline

Get the angle corresponding to a quaternion's rotation, in radians.

If you don't care about the rotation axis, this is more efficient than computeAngleAndAxis().

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
MOptthe option flags (alignment etc.) used for the rotation matrix argument. Can be deduced.
Parameters
matrixthe rotation matrix to inspect.
Returns
the angle of the rotation, in radians.
template<typename T , int QOpt, int VOpt>
void SurgSim::Math::computeAngleAndAxis ( const Eigen::Quaternion< T, QOpt > &  quaternion,
T *  angle,
Eigen::Matrix< T, 3, 1, VOpt > *  axis 
)
inline

Get the angle (in radians) and axis corresponding to a quaternion's rotation.

Note
Unit quaternions cover the unit sphere twice (q=-q). To make sure that the same rotation (q or -q)
returns the same Axis/Angle, we need a pi range for the angle.
We choose to enforce half the angle in the quadrant [0 +pi/2], which leads to an output angle in [0 +pi].
Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
QOptthe option flags (alignment etc.) used for the quaternion argument. Can be deduced.
VOptthe option flags (alignment etc.) used for the axis vector argument. Can be deduced.
Parameters
quaternionthe rotation quaternion to inspect.
[out]anglethe angle of the rotation in [0 +pi], in radians.
[out]axisthe axis of the rotation.
template<typename T , int MOpt, int VOpt>
void SurgSim::Math::computeAngleAndAxis ( const Eigen::Matrix< T, 3, 3, MOpt > &  matrix,
T *  angle,
Eigen::Matrix< T, 3, 1, VOpt > *  axis 
)
inline

Get the angle (in radians) and axis corresponding to a rotation matrix.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
MOptthe option flags (alignment etc.) used for the rotation matrix argument. Can be deduced.
VOptthe option flags (alignment etc.) used for the axis vector argument. Can be deduced.
Parameters
matrixthe rotation matrix to inspect.
[out]anglethe angle of the rotation, in radians.
[out]axisthe axis of the rotation.
template<typename T , int TOpt, int VOpt>
void SurgSim::Math::computeRotationVector ( const Eigen::Transform< T, 3, Eigen::Isometry, TOpt > &  end,
const Eigen::Transform< T, 3, Eigen::Isometry, TOpt > &  start,
Eigen::Matrix< T, 3, 1, VOpt > *  rotationVector 
)

Get the vector corresponding to the rotation between transforms.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
TOptthe option flags (alignment etc.) used for the transform arguments. Can be deduced.
VOptthe option flags (alignment etc.) used for the vector argument. Can be deduced.
Parameters
endthe transform after the rotation.
startthe transform before the rotation.
[out]rotationVectora vector describing the rotation.
template<class T , int MOpt>
T SurgSim::Math::distanceLineLine ( const Eigen::Matrix< T, 3, 1, MOpt > &  l0v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  l0v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  l1v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  l1v1,
Eigen::Matrix< T, 3, 1, MOpt > *  pt0,
Eigen::Matrix< T, 3, 1, MOpt > *  pt1 
)
inline

Determine the distance between two lines.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
l0v0,l0v1Points on Line 0.
l1v0,l1v1Points on Line 1.
[out]pt0The closest point on line 0.
[out]pt1The closest point on line 1.
Returns
The normal distance between the two given lines i.e. (pt0 - pt1).norm()
Note
We are using distancePointSegment for the degenerate cases as opposed to distancePointLine, why is that ??? (HS-2013-apr-26)
template<class T , int MOpt>
T SurgSim::Math::distancePointLine ( const Eigen::Matrix< T, 3, 1, MOpt > &  pt,
const Eigen::Matrix< T, 3, 1, MOpt > &  v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  v1,
Eigen::Matrix< T, 3, 1, MOpt > *  result 
)
inline

Calculate the normal distance between a point and a line.

Parameters
ptThe input point.
v0,v1Two vertices on the line.
[out]resultThe point projected onto the line.
Returns
The normal distance between the point and the line
template<class T , int MOpt>
T SurgSim::Math::distancePointPlane ( const Eigen::Matrix< T, 3, 1, MOpt > &  pt,
const Eigen::Matrix< T, 3, 1, MOpt > &  n,
d,
Eigen::Matrix< T, 3, 1, MOpt > *  result 
)
inline

Calculate the distance of a point to a plane.

Precondition
n needs to the normalized
Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
ptThe point to check.
nThe normal of the plane n (normalized).
dConstant d for the plane equation as in n.x + d = 0.
[out]resultProjection of point p into the plane.
Returns
The distance to the plane (negative if on the backside of the plane).
template<class T , int MOpt>
T SurgSim::Math::distancePointSegment ( const Eigen::Matrix< T, 3, 1, MOpt > &  pt,
const Eigen::Matrix< T, 3, 1, MOpt > &  sv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  sv1,
Eigen::Matrix< T, 3, 1, MOpt > *  result 
)
inline

Point segment distance, if the projection of the closest point is not within the segments, the closest segment point is used for the distance calculation.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
ptThe input point
sv0,sv1The segment extremities.
[out]resultEither the projection onto the segment or one of the 2 vertices.
Returns
The distance of the point from the segment.
template<class T , int MOpt>
T SurgSim::Math::distancePointTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  pt,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2,
Eigen::Matrix< T, 3, 1, MOpt > *  result 
)
inline

Calculate the normal distance of a point from a triangle, the resulting point will be on the edge of the triangle if the projection of the point is not inside the triangle.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
ptThe point that is being measured.
tv0,tv1,tv2The vertices of the triangle.
[out]resultThe point on the triangle that is closest to pt, if the projection of pt onto the triangle. plane is not inside the triangle the closest point on the edge will be used.
Returns
The distance between the point and the triangle, i.e (result - pt).norm()
template<class T , int MOpt>
T SurgSim::Math::distanceSegmentPlane ( const Eigen::Matrix< T, 3, 1, MOpt > &  sv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  sv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  n,
d,
Eigen::Matrix< T, 3, 1, MOpt > *  closestPointSegment,
Eigen::Matrix< T, 3, 1, MOpt > *  planeIntersectionPoint 
)
inline

Calculate the distance between a segment and a plane.

Precondition
n should be normalized
Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
sv0,sv1Endpoints of the segments.
nNormal of the plane n (normalized).
dConstant d in n.x + d = 0.
[out]closestPointSegmentPoint closest to the plane, the midpoint of the segment (v0+v1)/2 is being used if the segment is parallel to the plane. If the segment actually intersects the plane segmentIntersectionPoint will be equal to planeIntersectionPoint.
[out]planeIntersectionPointthe point on the plane where the line defined by the segment intersects the plane.
Returns
the distance of closest point of the segment to the plane, 0 if the segment intersects the plane, negative if the closest point is on the other side of the plane.
template<class T , int MOpt>
T SurgSim::Math::distanceSegmentSegment ( const Eigen::Matrix< T, 3, 1, MOpt > &  s0v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  s0v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  s1v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  s1v1,
Eigen::Matrix< T, 3, 1, MOpt > *  pt0,
Eigen::Matrix< T, 3, 1, MOpt > *  pt1,
T *  s0t = nullptr,
T *  s1t = nullptr 
)

Distance between two segments, if the project of the closest point is not on the opposing segment, the segment endpoints will be used for the distance calculation.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
s0v0,s0v1Segment 0 Extremities.
s1v0,s1v1Segment 1 Extremities.
[out]pt0Closest point on segment 0
[out]pt1Closest point on segment 1
[out]s0tAbscissa at the point of intersection on Segment 0 (s0v0 + t * (s0v1 - s0v0)).
[out]s1tAbscissa at the point of intersection on Segment 0 (s1v0 + t * (s1v1 - s1v0)).
Returns
Distance between the segments, i.e. (pt0 - pt1).norm()
template<class T , int MOpt>
T SurgSim::Math::distanceSegmentTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  sv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  sv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2,
Eigen::Matrix< T, 3, 1, MOpt > *  segmentPoint,
Eigen::Matrix< T, 3, 1, MOpt > *  trianglePoint 
)
inline

Calculate the distance of a line segment to a triangle.

Note that this version will calculate the normal of the triangle, if the normal is known use the other version of this function.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
sv0,sv1Extremities of the line segment.
tv0,tv1,tv2Triangle points.
[out]segmentPointClosest point on the segment.
[out]trianglePointClosest point on the triangle.
Returns
the the distance between the two closest points, i.e. (trianglePoint - segmentPoint).norm().
template<class T , int MOpt>
T SurgSim::Math::distanceSegmentTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  sv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  sv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2,
const Eigen::Matrix< T, 3, 1, MOpt > &  normal,
Eigen::Matrix< T, 3, 1, MOpt > *  segmentPoint,
Eigen::Matrix< T, 3, 1, MOpt > *  trianglePoint 
)
inline

Calculate the distance of a line segment to a triangle.

Precondition
n needs to be normalized.
Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
sv0,sv1Extremities of the line segment.
tv0,tv1,tv2Points of the triangle.
normalNormal of the triangle (Expected to be normalized)
[out]segmentPointClosest point on the segment.
[out]trianglePointClosest point on the triangle.
Returns
the distance between the two closest points.
template<class T , int MOpt>
T SurgSim::Math::distanceTrianglePlane ( const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2,
const Eigen::Matrix< T, 3, 1, MOpt > &  n,
d,
Eigen::Matrix< T, 3, 1, MOpt > *  closestPointTriangle,
Eigen::Matrix< T, 3, 1, MOpt > *  planeProjectionPoint 
)
inline

Calculate the distance of a triangle to a plane.

Precondition
n should be normalized.
Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
tv0,tv1,tv2Points of the triangle.
nNormal of the plane n (normalized).
dConstant d in n.x + d = 0.
closestPointTriangleClosest point on the triangle, when the triangle is coplanar to the plane (tv0+tv1+tv2)/3 is used, when the triangle intersects the plane the midpoint of the intersection segment is returned.
planeProjectionPointProjection of the closest point onto the plane, when the triangle intersects the plane the midpoint of the intersection segment is returned.
Returns
The distance of the triangle to the plane.
template<class T , int MOpt>
T SurgSim::Math::distanceTriangleTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  t0v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v2,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v2,
Eigen::Matrix< T, 3, 1, MOpt > *  closestPoint0,
Eigen::Matrix< T, 3, 1, MOpt > *  closestPoint1 
)
inline

Calculate the distance between two triangles.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
t0v0,t0v1,t0v2Points of the first triangle.
t1v0,t1v1,t1v2Points of the second triangle.
[out]closestPoint0Closest point on the first triangle, unless penetrating, in which case it is the point along the edge that allows min separation.
[out]closestPoint1Closest point on the second triangle, unless penetrating, in which case it is the point along the edge that allows min separation.
Returns
the distance between the two triangles.
template<class Scalar , int Dim>
bool SurgSim::Math::doAabbIntersect ( const Eigen::AlignedBox< Scalar, Dim > &  aabb0,
const Eigen::AlignedBox< Scalar, Dim > &  aabb1,
double  tolerance 
)

Determine whether two AABBs have an intersection with each other, for the calculation see http://www.gamasutra.com/view/feature/131790/simple_intersection_tests_for_games.php?page=3.

Template Parameters
Scalarnumeric type
Dimdimension of the space to be used
Parameters
aabb0first axis aligned bounding box
aabb1second axis aligned bounding box
tolerancethe bounding boxes will be considered bigger by this amount
Returns
true if there is an overlap between the two boxes
template<class Scalar , int Dim>
bool SurgSim::Math::doAabbIntersect ( const Eigen::AlignedBox< Scalar, Dim > &  a,
const Eigen::AlignedBox< Scalar, Dim > &  b 
)

Determine whether two AABBs overlap, using a minimal set of eigen calls, does not take a tolerance.

Template Parameters
Scalarnumeric type
Dimdimension of the space to be used
Parameters
afirst axis aligned bounding box
bsecond axis aligned bounding box
Returns
true if there is an overlap between the two boxes
template<class T , int MOpt>
bool SurgSim::Math::doesCollideSegmentTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  sv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  sv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2,
const Eigen::Matrix< T, 3, 1, MOpt > &  tn,
Eigen::Matrix< T, 3, 1, MOpt > *  result 
)
inline

Calculate the intersection of a line segment with a triangle See http://geomalgorithms.com/a06-_intersect-2.html#intersect_RayTriangle for the algorithm.

Precondition
The normal must be unit length
The triangle vertices must be in counter clockwise order in respect to the normal
Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
sv0,sv1Extremities of the segment.
tv0,tv1,tv2The triangle vertices. CCW around the normal.
tnThe triangle normal, should be normalized.
[out]resultThe point where the triangle and the line segment intersect, invalid if they don't intersect.
Returns
true if the segment intersects with the triangle, false if it does not
Note
HS-2013-may-07 This is the only function that only checks for intersection rather than returning a distance if necessary this should be rewritten to do the distance calculation, doing so would necessitate to check against all the triangle edges in the non intersection cases.
template<class T , int MOpt>
bool SurgSim::Math::doesIntersectBoxCapsule ( const Eigen::Matrix< T, 3, 1, MOpt > &  capsuleBottom,
const Eigen::Matrix< T, 3, 1, MOpt > &  capsuleTop,
const T  capsuleRadius,
const Eigen::AlignedBox< T, 3 > &  box 
)

Test if an axis aligned box intersects with a capsule.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
capsuleBottomPosition of the capsule bottom
capsuleTopPosition of the capsule top
capsuleRadiusThe capsule radius
boxAxis aligned bounding box
Returns
True, if intersection is detected.
template<class T , int MOpt>
bool SurgSim::Math::doesIntersectPlanePlane ( const Eigen::Matrix< T, 3, 1, MOpt > &  pn0,
pd0,
const Eigen::Matrix< T, 3, 1, MOpt > &  pn1,
pd1,
Eigen::Matrix< T, 3, 1, MOpt > *  pt0,
Eigen::Matrix< T, 3, 1, MOpt > *  pt1 
)
inline

Test if two planes are intersecting, if yes also calculate the intersection line.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
pn0,pd0Normal and constant of the first plane, nx + d = 0.
pn1,pd1Normal and constant of the second plane, nx + d = 0.
[out]pt0,pt1Two points on the intersection line, not valid if there is no intersection.
Returns
true when a unique line exists, false for disjoint or coinciding.
template<class T , int MOpt>
bool SurgSim::Math::doesIntersectTriangleTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  t0v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v2,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v2,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0n,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1n 
)
inline

Check if the two triangles intersect using separating axis test.

Algorithm is implemented from http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/pubs/tritri.pdf

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
t0v0,t0v1,t0v2Vertices of the first triangle.
t1v0,t1v1,t1v2Vertices of the second triangle.
t0nNormal of the first triangle, should be normalized.
t1nNormal of the second triangle, should be normalized.
Returns
True, if intersection is detected.
template<class T , int MOpt>
bool SurgSim::Math::doesIntersectTriangleTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  t0v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t0v2,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v0,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v1,
const Eigen::Matrix< T, 3, 1, MOpt > &  t1v2 
)
inline

Check if the two triangles intersect using separating axis test.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
t0v0,t0v1,t0v2Vertices of the first triangle.
t1v0,t1v1,t1v2Vertices of the second triangle.
Returns
True, if intersection is detected.
template<class T >
void SurgSim::Math::edgeIntersection ( dStart,
dEnd,
pvStart,
pvEnd,
T *  parametricIntersection,
size_t *  parametricIntersectionIndex 
)

Two ends of the triangle edge are given in terms of the following vertex properties.

  • Signed distance from the colliding triangle.
  • Projection on the separating axis. Get the intersection of this edge and the plane in terms of the projection on the separating axis.
    Template Parameters
    TAccuracy of the calculation, can usually be inferred.
    Parameters
    dStartSigned distance of the start of edge from the plane of the colliding triangle.
    dEndSigned distance of the end of edge from the plane of the colliding triangle.
    pvStartProjection of the start of edge from the plane of the colliding triangle.
    pvEndProjection of the end of edge from the plane of the colliding triangle.
    parametricIntersectionParametric representation of the intersection between the triangle edge and the plane in terms of the projection on the separating axis.
    parametricIntersectionIndexThe array index of parametricIntersection.
std::string SurgSim::Math::getMlcpConstraintTypeName ( MlcpConstraintType  constraintType)
inline
MlcpConstraintType SurgSim::Math::getMlcpConstraintTypeValue ( const std::string &  typeName)
inline
template<class Matrix >
Eigen::Block<Matrix> SurgSim::Math::getSubMatrix ( Matrix &  matrix,
size_t  blockIdRow,
size_t  blockIdCol,
size_t  blockSizeRow,
size_t  blockSizeCol 
)

Helper method to access a sub-matrix from a matrix, for the sake of clarity.

Template Parameters
MatrixThe matrix type to get the sub-matrix from
Parameters
matrixThe matrix to get the sub-matrix from
blockIdRow,blockIdColThe block indices
blockSizeRow,blockSizeColThe block size
Returns
The requested sub-matrix
Note
Disable cpplint warnings for use of non-const reference
Eigen has a specific type for Block that we want to return with read/write access
therefore the Matrix from which the Block is built from must not be const
template<class Vector >
Eigen::VectorBlock<Vector> SurgSim::Math::getSubVector ( Vector &  vector,
size_t  blockId,
size_t  blockSize 
)

Helper method to access a sub-vector from a vector, for the sake of clarity.

Template Parameters
VectorThe vector type to get the sub-vector from
Parameters
vectorThe vector to get the sub-vector from
blockIdThe block index
blockSizeThe block size
Returns
The requested sub-vector
Note
Disable cpplint warnings for use of non-const reference
Eigen has a specific type for VectorBlock that we want to return with read/write access
therefore the Vector from which the VectorBlock is built from must not be const
template<class Vector , class SubVector >
void SurgSim::Math::getSubVector ( const Vector &  vector,
const std::vector< size_t >  blockIds,
size_t  blockSize,
SubVector *  subVector 
)

Helper method to get a sub-vector per block from a vector, for the sake of clarity.

Template Parameters
VectorThe vector type
SubVectorThe sub-vector type
Parameters
vectorThe vector (containing the blocks in a sparse manner)
blockIdsVector of block indices (for accessing vector) corresponding to the blocks in vector
blockSizeThe block size
[out]subVectorThe sub-vector to store the requested blocks (blockIds) from vector into
template<typename T , int TOpt>
Eigen::Transform<T, 3, Eigen::Isometry> SurgSim::Math::interpolate ( const Eigen::Transform< T, 3, Eigen::Isometry, TOpt > &  t0,
const Eigen::Transform< T, 3, Eigen::Isometry, TOpt > &  t1,
t 
)
inline

Interpolate (slerp) between 2 rigid transformations.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
TOptthe option flags (alignment etc.) used for the Transform arguments. Can be deduced.
Parameters
t0The start transform (at time 0.0).
t1The end transform (at time 1.0).
tThe interpolation time requested. Within [0..1].
Returns
the transform resulting in the slerp interpolation at time t, between t0 and t1.
Note
t=0 => returns t0
t=1 => returns t1
template<typename T , int QOpt>
Eigen::Quaternion<T, QOpt> SurgSim::Math::interpolate ( const Eigen::Quaternion< T, QOpt > &  q0,
const Eigen::Quaternion< T, QOpt > &  q1,
t 
)
inline

Interpolate (slerp) between 2 quaternions.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
QOptthe option flags (alignment etc.) used for the quaternion arguments. Can be deduced.
Parameters
q0The start quaternion (at time 0.0).
q1The end quaternion (at time 1.0).
tThe interpolation time requested. Within [0..1].
Returns
the quaternion resulting in the slerp interpolation at time t, between q0 and q1.
Note
t=0 => returns either q0 or -q0
t=1 => returns either q1 or -q1
'Interpolate' has been created because slerp might not be enough in certain cases. This gives room for correction and special future treatment
template<typename T , int size, int TOpt>
Eigen::Matrix<T, size, 1, TOpt> SurgSim::Math::interpolate ( const Eigen::Matrix< T, size, 1, TOpt > &  previous,
const Eigen::Matrix< T, size, 1, TOpt > &  next,
t 
)

Interpolate (slerp) between 2 vectors.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
sizethe size of the vectors. Can be deduced.
TOptthe option flags (alignment etc.) used for the Vector arguments. Can be deduced.
Parameters
previousThe starting vector (at time 0.0).
nextThe ending vector (at time 1.0).
tThe interpolation time requested. Within [0..1], although note bounds are not checked.
Returns
the transform resulting in the slerp interpolation at time t.
Note
t=0 => returns vector 'previous'
t=1 => returns vector 'next'
template<class T , int MOpt>
void SurgSim::Math::intersectionsSegmentBox ( const Eigen::Matrix< T, 3, 1, MOpt > &  sv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  sv1,
const Eigen::AlignedBox< T, 3 > &  box,
std::vector< Eigen::Matrix< T, 3, 1, MOpt > > *  intersections 
)

Calculate the intersections between a line segment and an axis aligned box.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
sv0,sv1Extremities of the line segment.
boxAxis aligned bounding box
[out]intersectionsThe points of intersection between the segment and the box
template<class T , int MOpt>
bool SurgSim::Math::isCoplanar ( const Eigen::Matrix< T, 3, 1, MOpt > &  a,
const Eigen::Matrix< T, 3, 1, MOpt > &  b,
const Eigen::Matrix< T, 3, 1, MOpt > &  c,
const Eigen::Matrix< T, 3, 1, MOpt > &  d 
)
inline

Check whether the points are coplanar.

Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
a,b,c,dPoints to check for coplanarity.
Returns
true if the points are coplanar.
template<class T , int MOpt>
bool SurgSim::Math::isPointInsideTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  pt,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2,
const Eigen::Matrix< T, 3, 1, MOpt > &  tn 
)
inline

Check if a point is inside a triangle.

Note
Use barycentricCoordinates() if you need the coordinates
Precondition
The normal must be unit length
The triangle vertices must be in counter clockwise order in respect to the normal
Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
ptVertex of the point.
tv0,tv1,tv2Vertices of the triangle, must be in CCW.
tnNormal of the triangle (yes must be of norm 1 and a,b,c CCW).
Returns
true if pt lies inside the triangle tv0, tv1, tv2, false otherwise.
template<class T , int MOpt>
bool SurgSim::Math::isPointInsideTriangle ( const Eigen::Matrix< T, 3, 1, MOpt > &  pt,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv0,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv1,
const Eigen::Matrix< T, 3, 1, MOpt > &  tv2 
)
inline

Check if a point is inside a triangle.

Note
Use barycentricCoordinates() if you need the coordinates. Please note that the normal will be calculated each time you use this call, if you are doing more than one test with the same triangle, precalculate the normal and pass it. Into the other version of this function
Template Parameters
TAccuracy of the calculation, can usually be inferred.
MOptEigen Matrix options, can usually be inferred.
Parameters
ptVertex of the point.
tv0,tv1,tv2Vertices of the triangle, must be in CCW.
Returns
true if pt lies inside the triangle tv0, tv1, tv2, false otherwise.
bool SurgSim::Math::isSubnormal ( float  value)
inline

Check if a float value is subnormal.

Subnormal values have absolute values in the range std::numeric_limits<float>::denorm_min() <= x < std::numeric_limits<float>::min(), and can result in very slow floating point calculations under some conditions.

Parameters
valuethe value to check.
Returns
true if subnormal; false if not (normal, zero, infinite or NaN).
bool SurgSim::Math::isSubnormal ( double  value)
inline

Check if a double value is subnormal.

Subnormal values have absolute values in the range std::numeric_limits<double>::denorm_min() <= x < std::numeric_limits<double>::min(), and can result in very slow floating point calculations under some conditions.

Parameters
valuethe value to check.
Returns
true if subnormal; false if not (normal, zero, infinite or NaN).
template<typename T >
bool SurgSim::Math::isSubnormal ( const Eigen::DenseBase< T > &  value)
inline

Check if a matrix or a vector contains any subnormal floating-point values.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe base type used to describe the matrix or vector. Can usually be deduced.
Parameters
valuethe matrix or vector value to check.
Returns
true if any value is subnormal; false if none are (i.e. each is normal, zero, infinite or NaN).
template<typename T >
bool SurgSim::Math::isSubnormal ( const Eigen::QuaternionBase< T > &  value)
inline

Check if a quaternion contains any subnormal floating-point values.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe base type used to describe the quaternion. Can usually be deduced.
Parameters
valuethe quaternion value to check.
Returns
true if any value is subnormal; false if none are (i.e. each is normal, zero, infinite or NaN).
template<typename T >
bool SurgSim::Math::isSubnormal ( const Eigen::AngleAxis< T > &  value)
inline

Check if an angle/axis 3D rotation contains any subnormal floating-point values.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe scalar type used to describe the rotation. Can usually be deduced.
Parameters
valuethe rotation value to check.
Returns
true if any value is subnormal; false if none are (i.e. each is normal, zero, infinite or NaN).
template<typename T >
bool SurgSim::Math::isSubnormal ( const Eigen::Rotation2D< T > &  value)
inline

Check if a 2D rotation is described by an angle that is subnormal.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe scalar type used to describe the rotation. Can usually be deduced.
Parameters
valuethe 2D rotation value to check.
Returns
true if the angle is subnormal; false if not (normal, zero, infinite or NaN).
template<typename T , int D, int M, int O>
bool SurgSim::Math::isSubnormal ( const Eigen::Transform< T, D, M, O > &  value)
inline

Check if a transform contains any subnormal floating-point values.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe scalar type used to describe the transform. Can usually be deduced.
Dthe dimension used to describe the transform. Can usually be deduced.
Mthe mode value used to describe the transform. Can usually be deduced.
Othe options value used to describe the transform. Can usually be deduced.
Parameters
valuethe transform value to check.
Returns
true if any value is subnormal; false if none are (i.e. each is normal, zero, infinite or NaN).
bool SurgSim::Math::isValid ( float  value)
inline

Check if a float value is valid.

Zero, subnormal and normal numbers are valid; infinities and NaNs are not.

Parameters
valuethe value to check.
Returns
true if valid, false if not.
bool SurgSim::Math::isValid ( double  value)
inline

Check if a double value is valid.

Zero, subnormal and normal numbers are valid; infinities and NaNs are not.

Parameters
valuethe value to check.
Returns
true if valid, false if not.
template<typename T >
bool SurgSim::Math::isValid ( const Eigen::DenseBase< T > &  value)
inline

Check if a matrix or a vector is valid.

These quantities are valid if all of their elements are valid. Zero, subnormal and normal numbers are valid; infinities and NaNs are not.

Template Parameters
Tthe base type used to describe the matrix or vector. Can usually be deduced.
Parameters
valuethe matrix or vector value to check.
Returns
true if valid, false if not.
template<typename T >
bool SurgSim::Math::isValid ( const Eigen::QuaternionBase< T > &  value)
inline

Check if a quaternion is valid.

Quaternions are valid if all of their components are valid. Zero, subnormal and normal numbers are valid; infinities and NaNs are not.

Template Parameters
Tthe base type used to describe the quaternion. Can usually be deduced.
Parameters
valuethe quaternion value to check.
Returns
true if valid, false if not.
template<typename T >
bool SurgSim::Math::isValid ( const Eigen::AngleAxis< T > &  value)
inline

Check if an angle/axis 3D rotation is valid.

Angle/axis rotations are valid if the angle and the axis components are valid. Zero, subnormal and normal numbers are valid; infinities and NaNs are not.

Template Parameters
Tthe scalar type used to describe the rotation. Can usually be deduced.
Parameters
valuethe rotation value to check.
Returns
true if valid, false if not.
template<typename T >
bool SurgSim::Math::isValid ( const Eigen::Rotation2D< T > &  value)
inline

Check if a 2D rotation is valid.

2D rotations are valid if the rotation angle is valid. Zero, subnormal and normal numbers are valid; infinities and NaNs are not.

Template Parameters
Tthe scalar type used to describe the rotation. Can usually be deduced.
Parameters
valuethe rotation value to check.
Returns
true if valid, false if not.
template<typename T , int D, int M, int O>
bool SurgSim::Math::isValid ( const Eigen::Transform< T, D, M, O > &  value)
inline

Check if a transform is valid.

Transforms are valid if all of their components are valid. Zero, subnormal and normal numbers are valid; infinities and NaNs are not.

Template Parameters
Tthe scalar type used to describe the transform. Can usually be deduced.
Dthe dimension used to describe the transform. Can usually be deduced.
Mthe mode value used to describe the transform. Can usually be deduced.
Othe options value used to describe the transform. Can usually be deduced.
Parameters
valuethe transform value to check.
Returns
true if valid, false if not.
template<class Scalar , int Dim, int MType>
Eigen::AlignedBox<Scalar, Dim> SurgSim::Math::makeAabb ( const Eigen::Matrix< Scalar, Dim, 1, MType > &  vector0,
const Eigen::Matrix< Scalar, Dim, 1, MType > &  vector1,
const Eigen::Matrix< Scalar, Dim, 1, MType > &  vector2 
)

Convenience function for creating a bounding box from three vertices (e.g.

the vertices of a triangle)

Template Parameters
Scalarnumeric type
Dimdimension of the space to be used
MTypethe eigen type of the vectors
Returns
an AABB containing all the points passed
template<typename M , typename V >
Eigen::Transform<typename M::Scalar, M::RowsAtCompileTime, Eigen::Isometry> SurgSim::Math::makeRigidTransform ( const Eigen::MatrixBase< M > &  rotation,
const Eigen::MatrixBase< V > &  translation 
)
inline

Create a rigid transform using the specified rotation matrix and translation.

Template Parameters
Mthe type used to describe the rotation matrix. Can usually be deduced.
Vthe type used to describe the translation vector. Can usually be deduced.
Parameters
rotationthe rotation matrix.
translationthe translation vector.
Returns
the transform with the specified rotation and translation.
template<typename Q , typename V >
Eigen::Transform<typename Q::Scalar, 3, Eigen::Isometry> SurgSim::Math::makeRigidTransform ( const Eigen::QuaternionBase< Q > &  rotation,
const Eigen::MatrixBase< V > &  translation 
)
inline

Create a rigid transform using the specified rotation quaternion and translation.

Template Parameters
Qthe type used to describe the rotation quaternion. Can usually be deduced.
Vthe type used to describe the translation vector. Can usually be deduced.
Parameters
rotationthe rotation quaternion.
translationthe translation vector.
Returns
the transform with the specified rotation and translation.
template<typename T , int VOpt>
Eigen::Transform<T, 3, Eigen::Isometry> SurgSim::Math::makeRigidTransform ( const Eigen::Matrix< T, 3, 1, VOpt > &  position,
const Eigen::Matrix< T, 3, 1, VOpt > &  center,
const Eigen::Matrix< T, 3, 1, VOpt > &  up 
)
inline

Make a rigid transform from a eye point a center view point and an up direction, does not check whether up is colinear with eye-center The original formula can be found at http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml.

Template Parameters
typenameT T the numeric data type used for arguments and the return value. Can usually be deduced.
intVOpt VOpt the option flags (alignment etc.) used for the axis vector argument. Can be deduced.
Parameters
positionThe position of the object.
centerThe point to which the object should point.
upThe up vector to be used for this calculation.
Returns
a RigidTransform that locates the object at position rotated into the direction of center.
template<typename V >
Eigen::Transform<typename V::Scalar, V::SizeAtCompileTime, Eigen::Isometry> SurgSim::Math::makeRigidTranslation ( const Eigen::MatrixBase< V > &  translation)
inline

Create a rigid transform using the identity rotation and the specified translation.

Template Parameters
Vthe type used to describe the translation vector. Can usually be deduced.
Parameters
translationthe translation vector.
Returns
the transform with the identity rotation and the specified translation.
template<typename T , int VOpt>
Eigen::Matrix<T, 3, 3> SurgSim::Math::makeRotationMatrix ( const T &  angle,
const Eigen::Matrix< T, 3, 1, VOpt > &  axis 
)
inline

Create a rotation matrix corresponding to the specified angle (in radians) and axis.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
VOptthe option flags (alignment etc.) used for the axis vector argument. Can be deduced.
Parameters
anglethe angle of the rotation, in radians.
axisthe axis of the rotation.
Returns
the rotation matrix.
template<typename T , int VOpt>
Eigen::Quaternion<T> SurgSim::Math::makeRotationQuaternion ( const T &  angle,
const Eigen::Matrix< T, 3, 1, VOpt > &  axis 
)
inline

Create a quaternion rotation corresponding to the specified angle (in radians) and axis.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
VOptthe option flags (alignment etc.) used for the axis vector argument. Can be deduced.
Parameters
anglethe angle of the rotation, in radians.
axisthe axis of the rotation.
Returns
the rotation quaternion.
template<typename T , int VOpt>
Eigen::Matrix<T, 3, 3> SurgSim::Math::makeSkewSymmetricMatrix ( const Eigen::Matrix< T, 3, 1, VOpt > &  vector)
inline

Create a skew-symmetric matrix corresponding to the specified vector.

Skew-symmetric matrices are particularly useful for representing a portion of the vector cross-product.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
VOptthe option flags (alignment etc.) used for the vector argument. Can be deduced.
Parameters
vectorthe vector to be transformed.
Returns
the skew-symmetric matrix corresponding with the vector argument.
template<typename T , int QOpt>
Eigen::Quaternion<T, QOpt> SurgSim::Math::negate ( const Eigen::Quaternion< T, QOpt > &  q)
inline

Quaternion negation (i.e.

unary operator -)

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
QOptthe option flags (alignment etc.) used for the quaternion arguments. Can be deduced.
Parameters
qThe quaternion to negate
Returns
the negation of q (i.e. -q)
template<class Matrix , class SubMatrix >
void SurgSim::Math::setSubMatrix ( const SubMatrix &  subMatrix,
size_t  blockIdRow,
size_t  blockIdCol,
size_t  blockSizeRow,
size_t  blockSizeCol,
Matrix *  matrix 
)

Helper method to set a sub-matrix into a matrix, for the sake of clarity.

Template Parameters
MatrixThe matrix type
SubMatrixThe sub-matrix type
Parameters
subMatrixThe sub-matrix
blockIdRow,blockIdColThe block indices for row and column in matrix
blockSizeRow,blockSizeColThe size of the sub-matrix
[out]matrixThe matrix to set the sub-matrix into
bool SurgSim::Math::setSubnormalToZero ( float *  value)
inline

If the float value is subnormal, set it to zero.

Subnormal values have absolute values in the range std::numeric_limits<float>::denorm_min() <= x < std::numeric_limits<float>::min(), and can result in very slow floating point calculations under some conditions.

Parameters
[in,out]valuethe value to check and possibly modify.
Returns
true if the value was modified.
bool SurgSim::Math::setSubnormalToZero ( double *  value)
inline

If the double value is subnormal, set it to zero.

Subnormal values have absolute values in the range std::numeric_limits<double>::denorm_min() <= x < std::numeric_limits<double>::min(), and can result in very slow floating point calculations under some conditions.

Parameters
[in,out]valuethe value to check and possibly modify.
Returns
true if the value was modified.
template<typename T >
bool SurgSim::Math::setSubnormalToZero ( Eigen::DenseBase< T > *  value)
inline

Set all subnormal values in a matrix or a vector to zero.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe base type used to describe the matrix or vector. Can usually be deduced.
Parameters
[in,out]valuethe matrix or vector value to check and possibly modify.
Returns
true if any value was modified.
template<typename T >
bool SurgSim::Math::setSubnormalToZero ( Eigen::QuaternionBase< T > *  value)
inline

Set all subnormal values in a quaternion to zero.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe base type used to describe the quaternion. Can usually be deduced.
Parameters
[in,out]valuethe quaternion value to check and possibly modify.
Returns
true if any value was modified.
template<typename T >
bool SurgSim::Math::setSubnormalToZero ( Eigen::AngleAxis< T > *  value)
inline

Set all subnormal values in an angle/axis 3D rotation to zero.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe scalar type used to describe the rotation. Can usually be deduced.
Parameters
[in,out]valuethe rotation value to check and possibly modify.
Returns
true if any value was modified.
template<typename T >
bool SurgSim::Math::setSubnormalToZero ( Eigen::Rotation2D< T > *  value)
inline

If the angle of a 2D rotation is subnormal, set it to zero.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe scalar type used to describe the rotation. Can usually be deduced.
Parameters
[in,out]valuethe rotation value to check and possibly modify.
Returns
true if the value was modified.
template<typename T , int D, int M, int O>
bool SurgSim::Math::setSubnormalToZero ( Eigen::Transform< T, D, M, O > *  value)
inline

Set all subnormal values in a transform to zero.

Subnormal values have absolute values in the range std::numeric_limits<T>::denorm_min() <= x < std::numeric_limits<T>::min(), and can result in very slow floating point calculations under some conditions.

Template Parameters
Tthe base type used to describe the transform. Can usually be deduced.
Parameters
[in,out]valuethe transform value to check and possibly modify.
Returns
true if any value was modified.
template<class Vector , class SubVector >
void SurgSim::Math::setSubVector ( const SubVector &  subVector,
size_t  blockId,
size_t  blockSize,
Vector *  vector 
)

Helper method to set a sub-vector into a vector, for the sake of clarity.

Template Parameters
VectorThe vector type
SubVectorThe sub-vector type
Parameters
subVectorThe sub-vector
blockIdThe block index in vector
blockSizeThe size of the sub-vector
[out]vectorThe vector to set the sub-vector into
template<typename T , int MOpt>
Eigen::Matrix<T, 3, 1> SurgSim::Math::skew ( const Eigen::Matrix< T, 3, 3, MOpt > &  matrix)
inline

Extract the unique vector from the skew-symmetric part of a given matrix.

Template Parameters
Tthe numeric data type used for arguments and the return value. Can usually be deduced.
MOptthe option flags (alignment etc.) used for the matrix argument. Can be deduced.
Parameters
matrixthe matrix to compute the skew symmetric part from.
Returns
the unique vector defining the skew-symmetric part of the matrix.
Note
For any vector u, skew(makeSkewSymmetricMatrix(u)) = u
In general, returns the vector of the skew symmetric part of matrix: (matrix - matrix^T)/2
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::BoxShape  ,
BoxShape   
)
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::CapsuleShape  ,
CapsuleShape   
)
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::PlaneShape  ,
PlaneShape   
)
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::SphereShape  ,
SphereShape   
)
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::CylinderShape  ,
CylinderShape   
)
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::DoubleSidedPlaneShape  ,
DoubleSidedPlaneShape   
)
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::OctreeShape  ,
OctreeShape   
)
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::MeshShape  ,
MeshShape   
)
SurgSim::Math::SURGSIM_REGISTER ( SurgSim::Math::Shape  ,
SurgSim::Math::SurfaceMeshShape  ,
SurfaceMeshShape   
)
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( PlaneShape  )
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( CylinderShape  )
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( DoubleSidedPlaneShape  )
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( SphereShape  )
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( CapsuleShape  )
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( SurfaceMeshShape  )
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( BoxShape  )
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( OctreeShape  )
SurgSim::Math::SURGSIM_STATIC_REGISTRATION ( MeshShape  )

Variable Documentation

std::array< gaussQuadraturePoint, 100 > SurgSim::Math::gaussQuadrature100Points

100-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>, <x_3, w_3>, ..., <x_100, w_100>}

Note
Gauss-Legendre quadrature numerically evaluates the integral of a function \(f\) with a finite sum using some weights and specific points of evaluation of the function \(f\):
\(\int_{-1}^{+1} f(x) dx = \sum_{i=1}^n w_i f(x_i)\)
n is the number of points used to discretized the integral
\(x_i\) is the point to evaluate the function \(f\) with
\(w_i\) is the weight to assign to the function evaluation at the given point \(x_i\)
std::array< gaussQuadraturePoint, 1 > SurgSim::Math::gaussQuadrature1Point

1-point Gauss-Legendre quadrature {<x_1, w_1>}

Note
Gauss-Legendre quadrature numerically evaluates the integral of a function \(f\) with a finite sum using some weights and specific points of evaluation of the function \(f\):
\(\int_{-1}^{+1} f(x) dx = \sum_{i=1}^n w_i f(x_i)\)
n is the number of points used to discretized the integral
\(x_i\) is the point to evaluate the function \(f\) with
\(w_i\) is the weight to assign to the function evaluation at the given point \(x_i\)
std::array< gaussQuadraturePoint, 2 > SurgSim::Math::gaussQuadrature2Points

2-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>}

Note
Gauss-Legendre quadrature numerically evaluates the integral of a function \(f\) with a finite sum using some weights and specific points of evaluation of the function \(f\):
\(\int_{-1}^{+1} f(x) dx = \sum_{i=1}^n w_i f(x_i)\)
n is the number of points used to discretized the integral
\(x_i\) is the point to evaluate the function \(f\) with
\(w_i\) is the weight to assign to the function evaluation at the given point \(x_i\)
std::array< gaussQuadraturePoint, 3 > SurgSim::Math::gaussQuadrature3Points

3-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>, <x_3, w_3>}

Note
Gauss-Legendre quadrature numerically evaluates the integral of a function \(f\) with a finite sum using some weights and specific points of evaluation of the function \(f\):
\(\int_{-1}^{+1} f(x) dx = \sum_{i=1}^n w_i f(x_i)\)
n is the number of points used to discretized the integral
\(x_i\) is the point to evaluate the function \(f\) with
\(w_i\) is the weight to assign to the function evaluation at the given point \(x_i\)
std::array< gaussQuadraturePoint, 4 > SurgSim::Math::gaussQuadrature4Points

4-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>, <x_3, w_3>, <x_4, w_4>}

Note
Gauss-Legendre quadrature numerically evaluates the integral of a function \(f\) with a finite sum using some weights and specific points of evaluation of the function \(f\):
\(\int_{-1}^{+1} f(x) dx = \sum_{i=1}^n w_i f(x_i)\)
n is the number of points used to discretized the integral
\(x_i\) is the point to evaluate the function \(f\) with
\(w_i\) is the weight to assign to the function evaluation at the given point \(x_i\)
std::array< gaussQuadraturePoint, 5 > SurgSim::Math::gaussQuadrature5Points

5-points Gauss-Legendre quadrature {<x_1, w_1>, <x_2, w_2>, <x_3, w_3>, <x_4, w_4>, <x_5, w_5>}

Note
Gauss-Legendre quadrature numerically evaluates the integral of a function \(f\) with a finite sum using some weights and specific points of evaluation of the function \(f\):
\(\int_{-1}^{+1} f(x) dx = \sum_{i=1}^n w_i f(x_i)\)
n is the number of points used to discretized the integral
\(x_i\) is the point to evaluate the function \(f\) with
\(w_i\) is the weight to assign to the function evaluation at the given point \(x_i\)
const std::unordered_map<IntegrationScheme, std::string, std::hash<int> > SurgSim::Math::IntegrationSchemeNames