Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7056847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:54:56+00:00 2026-05-28T03:54:56+00:00

I have a quaternion (4×1) and an angular velocity vector(3×1) and I call a

  • 0

I have a quaternion (4×1) and an angular velocity vector(3×1) and I call a function to calculates the differential quaternion as explained in this web. The code looks like this:

    float wx = w.at<float>(0);
float wy = w.at<float>(1);
float wz = w.at<float>(2);
float qw = q.at<float>(3); //scalar component 
float qx = q.at<float>(0);
float qy = q.at<float>(1);
float qz = q.at<float>(2);

q.at<float>(0) = 0.5f * (wx*qw + wy*qz - wz*qy);    // qdiffx
q.at<float>(1) = 0.5f * (wy*qw + wz*qx - wx*qz);    // qdiffy
q.at<float>(2) = 0.5f * (wz*qw + wx*qy - wy*qx);    // qdiffz
q.at<float>(3) = -0.5f * (wx*qx + wy*qy + wz*qz);   // qdiffw

So now I have the differential quaternion stored in q and then I update the quaternion by simply adding this differential quaternion.

Is this method suitable for predicting movement of rigid objects or is there a better method to predict quaternion with angular velocity? This works but I am not getting the expected results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:54:57+00:00Added an answer on May 28, 2026 at 3:54 am

    There are a couple things that might be going on. You don’t mention re-normalizing that quaternion. Bad things will definitely happen if you’re not doing that. You also don’t say that you multiply the delta-quaternion components by the amount of time that has passed dt before you add them to the original quaternion. If your angular velocity is in radians per second, but you’re only stepping forward by a fraction of a second, you’ll step too far. However, even so, since you’re stepping through a discrete amount of time and trying to pretend that it’s infinitesimal, weird things are going to happen, particularly if your timestep or angular velocity is large.

    The physics engine, ODE, provides the option to update a body’s rotation from its angular velocity as though it were taking an infinitesimal step or to update using a finite sized step. The finite step is much more accurate, but involves some trig. functions and so is a little bit slower. The relevant ODE source code can be seen here, lines 300-321, with code finding the delta-quaternion here, line 310.

    float wMag = sqrt(wx*wx + wy*wy + wz*wz);
    float theta = 0.5f*wMag*dt;
    q[0] = cos(theta);  // Scalar component
    float s = sinc(theta)*0.5f*dt;
    q[1] = wx * s; 
    q[2] = wy * s;
    q[3] = wz * s;
    

    Where sinc(x) is:

    if (fabs(x) < 1.0e-4) return (1.0) - x*x*(0.166666666666666666667);
    else return sin(x)/x;
    

    This allows you to avoid the divide-by-zero problem and is still very precise.

    The quaternion q is then pre-multiplied onto the existing quaternion representation of the body’s orientation. Then, re-normalize.


    Edit–Where this formula comes from:

    Consider initial quaternion q0 and final quaternion q1 which results after rotating with angular velocity w for dt amount of time. All we’re doing here is changing the angular velocity vector into a quaternion and then rotating the first orientation by that quaternion. Both quaternions and angular velocities are variations on the axis-angle representation. A body that is rotated from its canonical orientation by theta around unit axis [x,y,z] will have the following quaternion representation of its orientation: q0 = [cos(theta/2) sin(theta/2)x sin(theta/2)y sin(theta/2)z].
    A body that is rotating theta/s around unit axis [x,y,z] will have angular velocity w=[theta*x theta*y theta*z]. So, in order to decide how much rotation will happen over dt seconds, we first extract the magnitude of the angular velocity: theta/s = sqrt(w[0]^2 + w[1]^2 + w[2]^2). Then we find the actual angle by multiplying by dt (and simultaneously divide by 2 for convenience in turning this into a quaternion). Since we need to normalize the axis [x y z], we’re also dividing by theta. That’s where the sinc(theta) part comes from. (since theta has an extra 0.5*dt in it from being the magnitude, we multiply that back out). The sinc(x) function is just using the Taylor series approximation of the function when x is small because it’s numerically stable and more accurate to do so. The ability to use this handy function is why we didn’t just divide by the actual magnitude wMag. Bodies that are not rotating very fast will have very small angular velocities. Since we expect this to be pretty common, we need a stable solution. What we end up with is a quaternion that represents a single step time step dt of rotation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a look at this picture alt text http://www.abbeylegal.com/downloads/2009-04-01/web%20part%20top%20line.jpg Does anyone know what css
I have a 3D camera with its current rotation stored as a quaternion, and
I have this method for rotating points in 3D using quaternions, but it seems
Have converted devise new session from erb to Haml but doens't work, this is
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Say you have a 2d object, you could easily divide this into 15 degree
I have a model rotated by a quaternion. I can only set the rotation,
I have a quaternion rotation, as usually described by 4 values: a b c
I have 2 rotation matrices (lets call them A and B) where: A =
I have a Quaternion representing the rotation of a 3D characters upper arm. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.