Getting Device Orientation

16 views
Skip to first unread message

Ebonair

unread,
May 23, 2012, 6:52:29 PM5/23/12
to vrjuggler-questions
I'm trying to get the orientation of our wand device. Right now I can
extract the position no problem, but the orientation isn't working
properly:

Matrix44f wandMatrix;//4x4 translational matrix representing
wand position
gmtl::Point3f wandPoint;//gtml representation of the wand's position
gmtl::EulerAngle<double, gmtl::XYZ> wandAngle;

//### Extract the wand position ###
wandMatrix = mWand->getData();
wandPoint = gmtl::makeTrans<gmtl::Point3f>(wandMatrix);
wandPos = Point3D(wandPoint[0], wandPoint[1], wandPoint[2]);

//### Extract the wand orientation ###
gmtl::Matrix44f invertedWandMatrix;
gmtl::invertFull(invertedWandMatrix, wandMatrix);

gmtl::Vec3f direction;
gmtl::Vec3f Zdir = gmtl::Vec3f(0.0f, 0.0f, -90.0f);
gmtl::xform(direction, invertedWandMatrix, Zdir);

cout << "Angle: " << direction[0] << ", " << direction[1] << ", " <<
direction[2] << endl;

If I do the following:

Change wand roll: no effect on any direction
Change wand pitch: affects direction[1] and direction[2]
Change wand yaw: affects direction[0] and direction[2]

How should I resolve this?

Ebonair

unread,
May 24, 2012, 1:38:13 PM5/24/12
to vrjuggler-questions
Ah, found it in the programmer's guide. Silly me for looking in the
API reference.
Reply all
Reply to author
Forward
0 new messages