Pablo Stark
Pablo Stark

Reputation: 682

Getting axis of rotation in osgSim::DOFTransform?

I'm working on a OSG model which contains several DOFTransform nodes. In order to perform geometric calculations on the 3D model I need to know which are the axis of rotation and the point where this axis is placed, is that possible?

Upvotes: 2

Views: 289

Answers (1)

Solkar
Solkar

Reputation: 1226

osgSim::DOFTransform http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00215.html

has

const osg::Vec3& osgSim::DOFTransform::getCurrentHPR() const;

to get the Euler angles for **H**eading, **P**itch and **R**oll,and

MultOrder osgSim::DOFTransform::getHPRMultOrder() const;

to get the convention intended to be used for the sequence of rotations.

The reference point can be determined by

const osg::Vec3& osgSim::DOFTransform::getCurrentTranslate () const;

Given a vector v expressed in coordinates of the frame which the translation t refers to, it's

v' = v - t

on which the rotations are to be applied.


For conversion of an Euler angle to an axis/angle representation pls. attend:

https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Conversion_formulae_between_formalisms

In addition:

Let M be the combined rotation matrix, e.g.

M = H * P * R

(H,P,R here denoting the respective Matrices for the given angles) and vectors v', v'' with

v'' = M * v'

which are not collinear, the axis searched for is simply their normalized cross product, and the angle can be found by applying basic trigonometry.

Upvotes: 1

Related Questions