OsgMatrixConversions.h File Reference

Conversions to and from OSG matrix types. More...

`#include "SurgSim/Math/Matrix.h"`
`#include <osg/Matrixf>`
`#include <osg/Matrixd>`
`#include <osg/Uniform>`

Go to the source code of this file.

## Namespaces

| SurgSim
| SurgSim::Graphics

## Functions

template<int MOpt>
const osg::Matrix2 | SurgSim::Graphics::toOsg (const Eigen::Matrix< float, 2, 2, MOpt > &matrix)
| Convert a fixed-size 2x2 matrix of floats to OSG. More...
template<int MOpt>
const osg::Matrix2d | SurgSim::Graphics::toOsg (const Eigen::Matrix< double, 2, 2, MOpt > &matrix)
| Convert a fixed-size 2x2 matrix of doubles to OSG. More...
const Eigen::Matrix< float, 2, 2, Eigen::RowMajor > | SurgSim::Graphics::fromOsg (const osg::Matrix2 &matrix)
| Convert from OSG to a 2x2 matrix of floats. More...
const Eigen::Matrix< double, 2, 2, Eigen::RowMajor > | SurgSim::Graphics::fromOsg (const osg::Matrix2d &matrix)
| Convert from OSG to a 2x2 matrix of doubles. More...
template<int MOpt>
const osg::Matrix3 | SurgSim::Graphics::toOsg (const Eigen::Matrix< float, 3, 3, MOpt > &matrix)
| Convert a fixed-size 3x3 matrix of floats to OSG. More...
template<int MOpt>
const osg::Matrix3d | SurgSim::Graphics::toOsg (const Eigen::Matrix< double, 3, 3, MOpt > &matrix)
| Convert a fixed-size 3x3 matrix of doubles to OSG. More...
const Eigen::Matrix< float, 3, 3, Eigen::RowMajor > | SurgSim::Graphics::fromOsg (const osg::Matrix3 &matrix)
| Convert from OSG to a 3x3 matrix of floats. More...
const Eigen::Matrix< double, 3, 3, Eigen::RowMajor > | SurgSim::Graphics::fromOsg (const osg::Matrix3d &matrix)
| Convert from OSG to a 3x3 matrix of doubles. More...
template<int MOpt>
const osg::Matrixf | SurgSim::Graphics::toOsg (const Eigen::Matrix< float, 4, 4, MOpt > &matrix)
| Convert a fixed-size 4x4 matrix of floats to OSG. More...
const Eigen::Matrix< float, 4, 4, Eigen::RowMajor > | SurgSim::Graphics::fromOsg (const osg::Matrixf &matrix)
| Convert from OSG to a 4x4 matrix of floats. More...
template<int MOpt>
const osg::Matrixd | SurgSim::Graphics::toOsg (const Eigen::Matrix< double, 4, 4, MOpt > &matrix)
| Convert a fixed-size 4x4 matrix of doubles to OSG. More...
const Eigen::Matrix< double, 4, 4, Eigen::RowMajor > | SurgSim::Graphics::fromOsg (const osg::Matrixd &matrix)
| Convert from OSG to a 4x4 matrix of doubles. More...

## Detailed Description

Conversions to and from OSG matrix types.

SurgSim's Eigen vectors are a single column, and matrix operations use postfix notation. OSG vectors are a single row and matrix operations use prefix notation,

For example, with Eigen, one might write:

Vector3d columnVector;
Matrix33d matrix;
Vector3d result = matrix * columnVector;

However, with OSG, this should be written in the form:

osg::Vec3d rowVector;
osg::Matrix3d columnMajorMatrix;
osg::Vec3d result = rowVector * columnMajorMatrix;

For the result to be the same, the OSG matrix data must be interpreted as column-major. These conversions handle that.