Posts

Showing posts with the label Quaternions

Converting Angular Velocity To Quaternion In OpenCV

Answer : If I understand properly you want to pass from this Axis Angle form to a quaternion. As shown in the link, first you need to calculate the module of the angular velocity (multiplied by delta(t) between frames), and then apply the formulas. A sample function for this would be // w is equal to angular_velocity*time_between_frames void quatFromAngularVelocity(Mat& qwt, const Mat& w) { const float x = w.at<float>(0); const float y = w.at<float>(1); const float z = w.at<float>(2); const float angle = sqrt(x*x + y*y + z*z); // module of angular velocity if (angle > 0.0) // the formulas from the link { qwt.at<float>(0) = x*sin(angle/2.0f)/angle; qwt.at<float>(1) = y*sin(angle/2.0f)/angle; qwt.at<float>(2) = z*sin(angle/2.0f)/angle; qwt.at<float>(3) = cos(angle/2.0f); } else // to avoid illegal expressions { qwt.at<float>(0) = qwt.at<float>(0)...