## 3D Math Problem

Moderator
Posts: 1,559
Joined: 2003.10
Post: #16
Eriond: You've fallen into a common trap. What you're essentially doing is using quaternions in the same way as euler angles, which still gives you gimbal lock. To use quaternions effectively, you'll have to shift your way of thinking about rotations by a little bit...

What you'll probably want to do is represent all of your rotations as a single axis/angle pair. No matter how you go about it, if you're rotating around each of the three axes separately, you'll run into problems. A single axis/angle pair can describe any possible rotation; a sequence of three rotations around a fixed set of axes can't.

Sage
Posts: 1,403
Joined: 2005.07
Post: #17
I just want to point out:
http://mathworld.wolfram.com/EulerAngles.html Wrote:According to Euler's rotation theorem, any rotation may be described using three angles.

Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
Moderator
Posts: 3,567
Joined: 2003.06
Post: #18
unknown Wrote:Sure you can, it just takes several days of searching to find enough information.
Mathematically sure. Conceptually no. What I was trying to communicate is that you can't actually understand them in the sense that they are four-dimensional. We live in a three-dimensional reality. Mentally it is easy to visualize what is happening with Euler angles. It is impossible with quats because of the extra dimension.
Luminary
Posts: 5,139
Joined: 2002.04
Post: #19
A quaternion ultimately represents an axis and an angle, which is perfectly easily visualized in 3D...
Member
Posts: 469
Joined: 2002.10
Post: #20
AnotherJake Wrote:Mathematically sure. Conceptually no. What I was trying to communicate is that you can't actually understand them in the sense that they are four-dimensional. We live in a three-dimensional reality. Mentally it is easy to visualize what is happening with Euler angles. It is impossible with quats because of the extra dimension.
It's easy to understand if you take it down one dimension...
Imagine a 2D plane with two equal length vectors A and B on it.
Now to rotate from vector A to vector B you can either sweep across the plane (ala yaw), or you can rotate out of the plane into the 3rd dimension.

Now imagine a half angle between vector A and B. Use this as the rotational axis. You rotate vector A around the half-angle axis into the third dimension, then continue rotating until you arrive at vector B back on the plane in 2D. If you abstract that up to 3D, then you have a quaternion. The quaternion rotates a 3D vector half way into 4D, then back down into your new desired 3D vector.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Moderator
Posts: 3,567
Joined: 2003.06
Post: #21
That's an interesting way to look at it kelvin! Abstracting 2D into 3D I can do. However, I still can't get my mind to abstract 3D into 4D. I just can't do it. Sorry.

OneSadCookie Wrote:A quaternion ultimately represents an axis and an angle, which is perfectly easily visualized in 3D...

Yeah, but it is an axis and an angle represented by x, y, z, w... Are you suggesting that you can clearly understand what each of those values of a quaternion mean at any given time? In 4D space?

[adding] I understand how quaternions work from the standpoint that adding the extra dimension allows us to solve 3D rotations without those axes implicitly constraining each other. I simply cannot visualize what is happening after I convert a 3D axis and angle into the fourth dimension. Once it gets converted back I'm happy though
Luminary
Posts: 5,139
Joined: 2002.04
Post: #22
x, y, z are the axis (scaled by the sine of half the angle) and w is 1 (scaled by the cosine of half the angle). So no, just by looking at the values, you don't necessarily know immediately what they mean, but you're only a divide, an inverse sine and a multiply away from something that's easily intelligible
Moderator
Posts: 3,567
Joined: 2003.06
Post: #23
That's what I'm saying. The human mind just wasn't designed to navigate 3D space in terms of four dimensions. But I see your angle (pun intended). It really is just an axis and an angle when it comes down to it. It's not like converting it to a quaternion turned it into pixie dust or something.
Member
Posts: 469
Joined: 2002.10
Post: #24
AnotherJake Wrote:That's what I'm saying. The human mind just wasn't designed to navigate 3D space in terms of four dimensions. But I see your angle (pun intended). It really is just an axis and an angle when it comes down to it. It's not like converting it to a quaternion turned it into pixie dust or something.
I think the easiest way to go from 2D/3D to 3D/4D is to think of 3 axis aligned 2D planes. Kinda like a box with the top and 2 sides missing.

If you're familiar with dot products, then you know how to project your 3D vectors (A and B) onto each of those planes. Now, from here you can imagine each of those projections as analogous to my previous 2D->3D example. Each projected rotation will pop off of that respective plane into an orthogonal 3D space. So, if you have planes XY, XZ, and YZ. you can think of their normal direction (Z, Y, and X respectively) as part of the component W dimension. I don't have the math off hand but I'm pretty sure you can mangle those values together into a W component for the rotation into 4D.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Moderator
Posts: 3,567
Joined: 2003.06
Post: #25
Wow! I think I actually get that.

Now somebody needs to make a visualizer...