# Quaternions, rotation, angular velocity, acceleration and prediction

This topic is 4868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

For the program I'm working on I need to be able to calculate the final orientation of an object, given it's current angular velocity and a rate of decelleration. The that I currently have working merely converts the final data from Euler angles into a quaternion, but what I want is to be able to do this with angular velocity and acceleration also represented as quaternions. Of course, with linear physics and with Euler angles it's simple: d = 0.5 * a * t^2 't', representing the time it takes decellerate to a stop, is found via the following: t = (v1 - v0) / a where 'v1' is the final velocity and v0 is the initial velocity. In the case of my problem 'v1' will be 0.0, of course, and 'a' will be negative to 'v0'. The problem with quaternions is everywhere. First of all, I can't even figure out how I'm going to calculate 't'. Once I've gotten that, I'm not sure how I would go about the final equation. Anyone know how I can do this?

##### Share on other sites
Why not work with axis/angle or an angular velocity vector and convert to quaternion as needed?

##### Share on other sites
In physics, rotational velocity is specified in sort of axis-angle form (vector with direction parallel to axis of rotation and length proportional to rotation speed), and it makes sense. Quaternions are good for storing rotations, but for rotational speeds them will "wrap over". So, normally most people use vector that gives axis of spin, and scalar specifying the speed. Or single vector as explained above.

Why quaternion doesn't make sense for rotation speed, example: something makes 5.1 revolutions per second around x axis. You can't store "5.1 revolutions" in quaternion, because quaternion can only store orientations but not turns. 2D analogy: you can use unit 2D vector to store orientation (direction), but if you want to store turns, you have to use angle, as in "turn screw 800 degrees to the left".

Your problem is easily solved with axis and angular velocity approach. Let your speed is w and deceleration is a, then t=w/a and turn when it comes at rest is x = 0.5*a*t^2 = 0.5*w^2/a
So you only need to convert x and axis of rotation into quaternion, using axis-angle to quaternion conversion. (if you worry about doing unnecessarry trigonometry, it is really unavoidable there, by the way.)

##### Share on other sites
So the problem is more that I'm looking at using quaternions in the wrong way, I guess? They're meant to only represent the final orientation? If so, that does make things a heck of alot easier. I had been looking to use quaternions for everything rotation related for the sake of consistency. . .

##### Share on other sites
Yeah kind of, its like youre trying to wear your left shoe as a hat :D. The key thing to keep in mind is that quaternions are numbers (which are also represntable as vectors in a Real Vector 4 space which follows a noncommutative algebra). An analogy I can think of is that quaternion numbers are to real numbers as Calculators are to Computers. Quaternions are not a weird kind of vector, they are fairly different entities mathematically.

Generally speaking, numbers are conceptual quantifications of certain type of information. Using quaternions, you can hold and say much more than rationals which in turn allow more expression than integers. For example, using quaternions the entirety of Maxwell's Equations (usually 4 equations) can be written as *F = J, where the * operator represents ict + Ñ (trivia) . Nonetheless, simply putting the angle as the scalar part and the axes in the complex part of the quaternion will not magically allow for the kinematics to work out. You simply created a quaternion which is no longer a unit quaternion but rather one with a scalar part whose value is equivalent to your angle value. In fact, as your d increases, your quaternion just becomes "bigger". In general, a pure quaternion can be associated with a rotation of 180o in 3 dimensions. There exists a derivative concept for quaternions but the mapping is certainly not 1 to 1. Unfortunately, yer gonna have to take the advice of the people above.

I recently wrote some stuff on quaternions whose goal is the laying of the intuitive foundations of the concept.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 16
• 15
• 28
• 12
• 14
• ### Forum Statistics

• Total Topics
634805
• Total Posts
3019368
×