///< Normalizes a quaternion kmQuaternion* kmQuaternionNormalize(kmQuaternion* pOut, const kmQuaternion* pIn) { kmScalar length = kmQuaternionLength(pIn); assert(fabs(length) > kmEpsilon); kmQuaternionScale(pOut, pIn, 1.0f / length); return pOut; }
/**< Returns the inverse of the passed Quaternion*/ kmQuaternion* kmQuaternionInverse(kmQuaternion* pOut, const kmQuaternion* pIn) { kmScalar l = kmQuaternionLength(pIn); if (fabs(l) < kmEpsilon) { pOut->x = 0.0; pOut->y = 0.0; pOut->z = 0.0; pOut->w = 0.0; return pOut; } pOut->x = -pIn->x; pOut->y = -pIn->y; pOut->z = -pIn->z; pOut->w = pIn->w; return pOut; }
/**< Normalizes a quaternion*/ kmQuaternion* kmQuaternionNormalize(kmQuaternion* pOut, const kmQuaternion* pIn) { kmScalar length = kmQuaternionLength(pIn); if (fabs(length) < kmEpsilon) { pOut->x = 0.0; pOut->y = 0.0; pOut->z = 0.0; pOut->w = 0.0; return pOut; } kmQuaternionFill(pOut, pOut->x / length, pOut->y / length, pOut->z / length, pOut->w / length ); return pOut; }
///< Returns the inverse of the passed Quaternion kmQuaternion* kmQuaternionInverse(kmQuaternion* pOut, const kmQuaternion* pIn) { kmScalar l = kmQuaternionLength(pIn); kmQuaternion tmp; if (fabs(l) > kmEpsilon) { pOut->x = 0.0; pOut->y = 0.0; pOut->z = 0.0; pOut->w = 0.0; return pOut; } ///Get the conjugute and divide by the length kmQuaternionScale(pOut, kmQuaternionConjugate(&tmp, pIn), 1.0f / l); return pOut; }