forked from simlrh/OSVR-Kinect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KinectMath.cpp
21 lines (16 loc) · 879 Bytes
/
KinectMath.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "KinectMath.h"
void boneSpaceToWorldSpace(OSVR_Quaternion* q) {
Eigen::Quaterniond quaternion = osvr::util::fromQuat(*q);
// Rotate bone quaternion around its own x axis
Eigen::AngleAxisd rotationAxis(M_PI / 2, quaternion._transformVector(Eigen::Vector3d::UnitX()));
Eigen::Quaterniond worldSpace = rotationAxis * quaternion;
osvr::util::toQuat(worldSpace, (*q));
}
void offsetTranslation(OSVR_Vec3* translation_offset, OSVR_Vec3* translation) {
osvrVec3SetX(translation, osvrVec3GetX(translation) - osvrVec3GetX(translation_offset));
osvrVec3SetY(translation, osvrVec3GetY(translation) - osvrVec3GetY(translation_offset));
osvrVec3SetZ(translation, osvrVec3GetZ(translation) - osvrVec3GetZ(translation_offset));
}
void applyOffset(OSVR_PoseState* offset, OSVR_PoseState* poseState) {
offsetTranslation(&(offset->translation), &(poseState->translation));
}