Why quaternions




















The plaque commemorating the discovery of quaternions by William Rowan Hamilton. Yesterday marked a significant anniversary whose importance is more subtle than the usual ones we celebrate. The plaque shown on the right commemorates the discovery. For physics enthusiasts: Hamilton is the same man who discovered Hamiltonian dynamics, which in turn underlies quantum mechanics and much of chaos theory.

The imaginary unit is the square root of Illustration of the complex plane: the connection between complex numbers and points in two dimensions. Four points are plotted so you can see the correspondence between x and y coordinates and the real and imaginary parts of the complex numbers. Complex numbers are the sum of a real number and an imaginary number. Just as you can place a real number on the number line, you can place a complex number on the complex plane : the x coordinate is the real part, while the y coordinate is the imaginary part.

This means complex numbers are a very simple way to represent two-dimensional quantities location on a map, for example. The math of complex numbers is very rich, but they also play many roles in physics and engineering, too many to list here.

The numerical issues come up when dealing with multiple consecutive rotations of an orientation. Imagine you have an object in space. And every timeslice, you apply a small change of yaw to it. After each change, you need to re-normalize the orientation; otherwise, precision problems will creep in and screw things up.

If you use matrices, each time you do matrix multiplication, you must re-orthonormalize the matrix. The matrix that you are orthonormalizing is not yet a rotation matrix, so I wouldn't be too sure about that easy orthonormalization.

However, I can be sure about this:. It won't be as fast as a 4D vector normalization. That's what quaternions use to normalize after successive rotations. Quaternion normalization is cheap. Even specialized rotation matrix normalization will not be as cheap. Again, performance matters. There's also another issue that matrices don't do easily: interpolation between two different orientations.

When dealing with a 3D character, you often have a series of transformations defining the location of each bone in the character. This hierarchy of bones represents the character in a particular pose. In most animation systems, to compute the pose for a character at a particular time, one interpolates between transformations. This requires interpolating the corresponding transformations. Interpolating two matrices is At least, it is if you want something that resembles a rotation matrix at the end.

After all, the purpose of the interpolation is to produce something part-way between the two transformations. For quaternions, all you need is a 4D lerp followed by a normalize.

That's all: take two quaternions and linearly interpolate the components. Normalize the result. If you want better quality interpolation and sometimes you do , you can bring out the spherical lerp. This makes the interpolation behave better for more disparate orientations.

This math is much more difficult and requires more operations for matrices than quaternions. Huge disadvantage : Normalization! Ghram-Shmit is asymmetrical, which does not give a higher order accurate answer when doing differential equations. More sophisticated methods are very complex and expensive. Moderate disadvantage : Multiplication and applying to a vector is slow with trig.

More code and debugging to automatically rescale it when it gets near 2pi. As you already seem to understand, quaternions encode a single rotation around an arbitrary axis as opposed to three sequential rotations in Euler 3-space. This makes quaternions immune to gimbal lock. I could go on, but quaternions are just one possible tool to use. If they do not suit your needs, then do not use them. We absolutely do not just want that.

There is a very important subtlety that lots of people miss. The construction you're talking about draw the triangles and use trig, etc. But there are infinitely many rotations that will do this. In particular, I can come along after you've done your rotation, and then rotate the whole system around the X' vector.

That won't change the position of X' at all. The combination of your rotation and mine is equivalent to another single rotation since rotations form a group. In general, you need to be able to represent any such rotation. It turns out that you can do this with just a vector. That's the axis-angle representation of rotations. But combining rotations in the axis-angle representation is difficult.

Quaternions make it easy, along with lots of other things. Basically, quaternions have all the advantages of other representations, and none of the drawbacks. Though I'll admit that there may be specific applications for which some other representation may be better.

It's worth bearing in mind that all the properties related to rotation are not truly properties of Quaternions: they're properties of Euler-Rodrigues Parameterisations , which is the actual 4-element structure used to describe a 3D rotation.

The Dublin start-up making the future better with an appreciation for innovation. Commenting on The Irish Times has changed. To comment you must now be an Irish Times subscriber.

The account details entered are not currently associated with an Irish Times subscription. Please subscribe to sign in to comment. You should receive instructions for resetting your password. When you have reset your password, you can Sign In. Please choose a screen name. This name will appear beside any comments you post.

Your screen name should follow the standards set out in our community standards. Screen Name Selection. Only letters, numbers, periods and hyphens are allowed in screen names.

Please enter your email address so we can send you a link to reset your password. Your Comments. Sign In Sign Out. We reserve the right to remove any content at any time from this Community, including without limitation if it violates the Community Standards.

We ask that you report content that you in good faith believe violates the above rules by clicking the Flag link next to the offending comment or by filling out this form. New comments are only accepted for 3 days from the date of publication. Subscriber Only. I want to add one application of quaternions. In multiantenna radio transmission the so called Alamouti code is based on the algebra of Hamiltonian quaternions.

That Wikipedia article is a bit more general about Space-Time coding, but you can find the Alamouti construction there. The quaternion algebra shows there as a way of disentangling two Alamouti coded signals transmitted by a pair of antennas. The advantages come from the fact that even if the signal from one antenna is lost for a particular receiver due to sitting in a node for that particular radio wave , then the signal from the other antenna saves the day. A moving receiver will drop a signal from one antenna in a random fashion, so when two independent antennas are used in this way total signal loss becomes a rarer event.

It uses a Quaternion object to represent rotation of various geometries. Modern Inertial Navigation programs use quaternions to represent rotations both of the craft body frame pitch, yaw, roll and geomatic position lat, long. Actually since these programs integrate measurements in the millisecond range, this use of quaternions is an example of calculus on a manifold, since the three dimensional sphere is a smooth manifold.

These all show up when either multiplying two quaternions or taking a 4-derivative of a quaternion-valued function. In 4D, vectors and quaternions can be isomorphic the same thing, just a different name. For rotations, quaternions are superior to using Euler angles. The reason is that quaternions avoid a problem known as gimbal lock.

That happens if two of the three rotational axes happen to align. When then a small change makes the system make a big jump. There certainly is a huge amount of overlap between quaternions and vectors in 4D.

There is much new to figure out too. For example, I know how to make animations out of quaternion expressions: think analytic animations, a 21th century update to analytic geometry.

In the late 80's at Kaiser Electronics I developed software to combine three 3-D rotations by multiplying their quaternions for pointing to a target like an approaching missile or aircraft using a fighter pilot's helmet mounted display: orientations of target to ground reference frame, aircraft to ground, and helmet to aircraft.

Everyone else in the company used much slower 4-D matrix multiplication, having never heard of quaternions as they were not in their computer graphics "bible" by Foley and Van Dam. Some years later I saw that book somewhere and saw quaternions mentioned in it. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Learn more. Real world uses of Quaternions? Ask Question.



0コメント

  • 1000 / 1000