# Linear Algebra Problem: Solving for Euler between two ordered bases

Tags:
1. Jun 24, 2017

### Elroy

1. The problem statement, all variables and given/known data
Linear Algebra Problem: Solving for Euler between two ordered bases

I've got a problem I need to solve, but I can't find a clean solution.

Let me see if I can outline the problem somewhat clearly. Okay, all of this will be in 3D space. In this space, we can define some origin. Typically, in my situation, this will be a point on the floor in the middle of some room. Next, we need to define X+, Y+, and Z+ in the room. Think of the X+ and Y+ as a piece of graph-paper lying on the floor with its origin on the room's origin. The Z+ is simply the third (Up) dimension.

Okay, with this information, we can define any other point in the room, even points that aren't on the floor. They'll just have a Z+ value other than zero. So, to represent any arbitrary point in the room, we might have a vector of three scalers:

Now, that room origin and axis system is often called an "ordered basis", or just a "basis".

I should briefly talk about something else too, the right-hand-rule. Basically, this states that, while you're looking down any axis at the origin, counter-clockwise rotations are positive, and clockwise rotations are negative. It's easy to visualize this as a piece of graph paper. You don't often think about it, but you're looking down the Z-axis when you're looking at graph paper. Rotations around this Z-axis around the origin are positive if they're counter-clockwise, rotating toward Y+ off of the X+ axis, which typically shoots off to the right. If we extrapolate this to 3-axes (3D), this is the right-hand-rule. Here's an image I once made trying to illustrate this:

Okay, forging on. Again, we've defined a "basis" (origin, X+ direction, Y+ direction, and Z+ direction) for our room. However, in truth, we can define any basis we like, so long as it's got an origin, an X+ direction, a Y+ direction, and a Z+ direction. You could think of the origin as the point in the above figure where the red, green, and blue lines converge. And then the X+, Y+, and Z+ directions are three points anywhere along the red, green, and blue lines. (Ideally, these lines are exactly one unit long, but this isn't absolutely required.) Also, as another FYI, these three directions are required to be orthogonal.

Since we can actually define any basis we like, we might imagine a basis defined as four of our above point-vectors, an origin, an X-axis direction, a Y-axis direction, and a Z-axis direction. The origin will always be in reference to our room's basis. However, the other three vectors can be rotated such that they're not parallel to the room's axes (X+, Y+, Z+).

Ok, one last piece of groundwork. To rotate from one basis to another, we can have what we call Euler angles. This could be thought of as another structure with three scalers. However, this time, they’re angles.
We can also talk about a translation (movement of the origin), but I'm mostly concerned about the rotation, so let's just forget changes in the origin of our two bases.

(Also, some might be having visions of quaternions and/or transformation matrices, but let's set those aside for now too.)

Ideally, what I'd like is a clean solution that solves for the Euler angles that would rotate one basis to another basis. In other words, given two bases (defined as above), how would I solve for the Euler angles? And the answer must follow the right-hand-rule.

Thanks in advance to all who take an interest in this. Also, just as an FYI, this isn’t some homework assignment. It’s actually for a project intended to help better understand children with walking disabilities.

Thanks,
Elroy

2. Jun 24, 2017

### scottdave

Could you maybe give some sort of example. You want to solve for the Euler angles for the new basis, but what exactly is defining the new basis? Quarternions may be something for you to look at, in a real application, though. There are already many software applications, which use this approach.

3. Jun 24, 2017

### Elroy

Hi scottdave,

I'll be writing the software myself to do this, but I've got to understand how to do it first. And yes, I may get into quaternions before I'm done.

Let me see if I can pull together some figures to illustrate an example. Alright, the following figure represents a basis in 3D space:

We can represent this basis with four vectors (or points) (with each vector having an X, Y, & Z component). We'll call the vector where the lines converge the "origin". For simplicity, we can think of this as <0,0,0> but it doesn't necessarily have to be.

Next, we've got a vector for the point on axis X, a vector for the point on axis Y, and a vector for the point on axis Z. The combination of these four vectors makes up an ordered basis.

Now, we can rotate the entire basis if we like. It's not totally easy to illustrate on a 2D screen, but the following is a rotated basis:

Now, if I have a set of Euler angles, I can actually work out how to rotate one basis to another basis. However, what I'm after is the opposite. Let me superimpose the two bases, with the lighter one being the starting basis, and the darker one (primes) being the new basis. (Actually, I did the primes backwards, but you should still get the idea.)

Now, let's say I've got both of these bases. What I'd like to solve for is the set of Euler angles between the two. The input will be four vectors representing basis#1 and four vectors representing basis#2. And the output I'd like will be three angles (Euler angles), following right-hand-rule.

Maybe that'll help,
Elroy