Tag Info

Hot answers tagged

18

Quaternions solve a few problems elegantly: They are as compact as axis-angle representations (4 scalar values) They are easily converted to and from matrix representations Interpolation works from any start to end angle without special casing They never exhibit gimbal lock You can get around these issues with other representations, but quaternions are a ...


16

There is an entire 600 page book on "Visualizing Quaternions": http://books.google.ca/books?id=CoUB09xzme4C&lpg=PP1&ots=uEdJHsni9y&dq=Visualizing%20Quaternions&pg=PP1#v=onepage&q&f=false The book is actually quite good, covering a wide range of topics. It starts with a good introduction to game related linear algebra, it talks about ...


14

In short You only need to change T in your SQT form. Replace the translation vector v with v' = v-invscale(p-invrotate(p)) where v is the initial translation vector, p is the point around which you want the rotation to occur, and invrotate and invscale are the inverses of your rotation and scale. Quick demonstration Let p be the point around which you ...


10

All of the canonical rotational formulas used to derive your rotation matrices are for rotation about the origin. If you would like instead to apply that rotation around a specific point, you must first offset the origin -- or, equivalently, move the object so the point you want to rotate about is at the origin. Consider the 2D case first, because it is ...


9

There are more than one ways to do it. You can calculate the absolute orientation or the rotation relative to your avatar, that means your new orientation = avatarOrientation * q. Here is the latter one: Calculate the rotation axis by taking the cross product of your avatar's unit forward vector and the unit vector from avatar to target, the new forward ...


9

Given only a point and a direction there is no defined 'right' or 'left'. Imagine being a falling raindrop, which direction is right or left for you in that case? In order to calculate (or even define) a right or left you need two directions, typically forward and up. You seem to already have a forward direction, so you need to define a up direction. ...


8

Linear Algebra is the foremost discipline for 3d graphics programming simply because it's the mathematical language for describing spatial geometry. Your other three topics are really just subsets of linear algebra: Vectors are a way of thinking about points in space Matrices are ways of thinking about transformations of space and objects: translating ...


7

For the motion curve, I'd suggest using Hermite curves. You simply give a starting point/velocity and an ending point/velocity, and it creates a nice and smooth curve between those two. Use the ending point/velocity of the first pair of points as the starting point/velocity of the next pair of points and you have a nice long and winding curve that is ...


7

Quaternions are associative: you mention that your solution is: newRot = oldRot * (inverse oldRot * worldRot) * oldRot which is the same as: newRot = oldRot * inverse oldRot * worldRot * oldRot which is the same as: newRot = identity * worldRot * oldRot newRot = worldRot * oldRot which actually brings you back to what's really happening: ...


5

While you haven't shown the necessary code to verify my assumption here, I can almost guarantee that your problem is actually that this line: cameraRot.ToAxisAngle(out axis, out angle); is returning an angle value expressed in radians, while GL.Rotate(angle, axis); wants angle to be provided in degrees. To fix it, you need to convert the angle value ...


5

Frankly, I would continue to use quaternions if you are already using them and comfortable with them. It doesn't seem to me like it's worthwhile to build out a whole system -- if even it's a small one -- to handle fixed sets of rotations when you can simply do that on top of a system that handles arbitrary ones. Furthermore, you can address the floating ...


5

First of all, q^(-1) is not -q/magnitude(q); it's q*/(magnitude(q))^2 (q* is the conjugate; that negates all the components except the real one). Of course, you can leave off the division by the magnitude if all your quaternions are normalized already, which they typically would be in a rotation system. As for the multiplication with a vector, you just ...


5

It seems that most engines do have those rotation methods. XNA has one in it's Vector3 struct. // Returns a new Vector3 that results from the rotation. public static Vector3 Transform ( Vector3 value, Quaternion rotation ) three.js has the function exactly as you wrote it. In Unity's case, their Vector3.Rotate() method might be internally ...


4

A torque has an axis and a magnitude, so in principle you can represent it as a quaternion. However, you have two problems. The first is that your parallel is wrong. torque :: force as orientation :: position, so you need to integrate it twice. Secondly, the way you're applying it is wrong. Question: given a quaternion representing a rotation of a certain ...


4

Although rotation-matrices and unit-quaternions both can represent an orientation/rotation in 3D space, that does not mean that negating each of its individual terms will result in the same geometrical operation. 1. Negating each number of a unit-quaternion There are always 2 unit-quaternions that represent a single unique orientation. One on each ...


4

The problem is neither of the conversion functions, the problem is the input matrix. It is not an affine transformation matrix, because the rotational part is not a pure rotation matrix, it has one or more flipping/negated axis in it. Only Rotation matrices can be converted to quaternions. More specifically rotation matrices are orthogonal matrices with ...


4

Actually, it turns out that you can't have it 'both ways': if your intention is to not have any sense of 'absolute orientation' on the sphere (that is, if the players aren't always e.g. facing towards the poles), then you'll need to have a notion of player orientation. This is because, contrary to what intuition might suggest, movement on the sphere is not ...


4

Your problem is purely two-dimensional, in the plane formed by the sphere centre and your source and destination points. Using quaternions is actually making things more complex, because in addition to a position on a 3D sphere, a quaternion encodes an orientation. You may already have something to interpolate on a circle, but just in case, here is some ...


4

What you are looking for is the LookAt algorithm. OpenGL already has that in a nice function: gluLookAt, although it multiplies the current matrix instead of returning it to you so you may need some push/pop trickery to get at it. If you want to do it yourself, there are two ways; by constructing a transformation matrix, or by using quaternions. Here's the ...


3

There are only 24 possible orientations achievable by 90° rotations around coordinate axis, which form the rotation group of a cube, also known as the chiral octahedral symmetry group. Since there are only 24 elements, you could easily build a multiplication table for them. (In fact, you only need a 24 × 6 table, since only 6 of the elements are ...


3

Are you sure your code for quaternion multiplication and your code for quaternion matrix converion is correct? I had a typo in one of my formulas once that cost me nearly half a day. btw... http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/index.htm is a great reference for quaternion math.


3

You do not necessarily need an alternate visualization technique for quaternions versus matrices. When you visualize your rotation matrix as the 3 axes gizmo, what you're really visualizing is an orientation. Since the quaternion also represents an orientation, consider continuing to use your 3 axes gizmo as your mind's eye visualization object. Rarely, ...


3

If your Vector3 stores an euler angle (yaw, pitch, roll) you can use the following static method directly: Quaternion quaternion = Quaternion.CreateFromYawPitchRoll(vector.X, vector.Y, vector.Z); On the other hand, if you're not storing an euler angle, but just the direction (or forward vector) of the camera/object, then bear in mind that generally a ...


3

The SLERP usage you mention is a specific case of a more general attribute of quaternions: you can smoothly interpolate between different rotation values. When interpolating the rotation values of euler angles you get weird looking movements, and there just isn't logically any way to interpolate the values of axis-angle rotations (well, aside from two ...


3

From your description of your problem, it sounds like the heart of the matter might be that your representation is currently missing data. A bone isn't simply the vector from one joint to the next — it's a full transformation matrix representing the orientation of the local frame, either with respect to world space or with respect to the local frame ...


3

First observation: The inverse of q is not -q/magnitude(q), that is completely wrong. Rotations with quaternions imply that these 4D complex number equivalents have unitary norm, hence lie on the S3 unit sphere in that 4D space. The fact that a quat is unitary means that its norm is norm(q)^2=q*conjugate(q)=1 and that means that the quat's inverse is its ...


3

if I just transpose that rotationMatrix and plug it into the 3x3 section of the view matrix, then negate the camera's position and plug it into the translation section of the view matrix That sounds suspicious to me. It sounds like your rotation matrix is the desired camera-to-world rotation, and you're trying to invert it to get the world-to-camera ...


3

You could decompose your quaternion into a yaw/pitch/roll set of angles, but that's overkill usually. Instead of composing your quaternions like this: cameraOrientation = cameraOrientation * framePitch * frameYaw; Try this: cameraOrientation = framePitch * cameraOrientation * frameYaw; It will then never generate tilt/roll and is equivalent to storing ...


3

Expressing rotations with quaternions can be done from an axis-angle representation, but not in a single way. For that same axis angle (w, a) pair, you get two quaternions performing the same task. One has its components based directly on the w vector and the a angle, the other has the same components, but negated. This is normal, since they describe the ...


3

Rotating a point p using a quaternion q is done with q * [0, p] / q. Replacing q with -q has absolutely no effect on the result. If your rotations "go the wrong direction" when the sign of the quaternion changes, then the problem lies in the way you use the quaternions to rotate points.



Only top voted, non community-wiki answers of a minimum length are eligible