A certain vector of one axis, how to find the vectors of the other two axes?

This is a math problem. I'm not quite sure how to do this. The vector is not aligned along the axis, so just rotating 90 degrees around x, y or z will not necessarily give me other axes.

+7
math vector rotation
source share
4 answers

I can think of several different scenarios that you might ask about.


Given: Pre-existing coordinate system

  • In a 2D system, your axes / bases are always [1,0] and [0,1] - x and y axes.

  • In a three-dimensional system, your axes / bases are always [1,0,0] , [0,1,0] and [0,0,1] - x, y and z.


Given: One axis in a coordinate system with an arbitrary base

If you have one axis in a 2D coordinate system of an arbitrary basis, the other axis is an orthogonal vector.

To rotate a vector orthogonally counterclockwise :

 [x_new, y_new] = [ -y_old, x_old] 

To rotate a vector orthogonally clockwise :

 [x_new, y_new] = [ y_old, -x_old] 

Summarizing:

 Given: x-axis = [ a, b] Then: y-axis = [-b, a] Given: y-axis = [ c, d] Then: x-axis = [ d, -c] 

Given: Two axes in a three-dimensional coordinate system of an arbitrary basis

To do this, find a cross product.

 [a,b,c] x [d,e,f] = [ b*f - c*e, c*d - a*f, a*e - b*d ] 

Following these three recommendations:

  • (x axis) x (y axis) = (z axis)
  • (y axis) x (z axis) = (x axis)
  • (z axis) x (x axis) = (y axis)

Given: One axis in a three-dimensional coordinate system of an arbitrary basis

There is not enough information to find a unique solution to this problem. This is due to the fact that if you look at the second case (one axis in a two-dimensional coordinate system of an arbitrary basis), you first need to find the orthogonal vector. However, there are an infinite number of possible orthogonal vectors for one axis in three-dimensional space!

However, you can find one of the possible solutions.

One way to find an arbitrary one of these orthogonal vectors is by finding any vector [d,e,f] where:

 [a,b,c] = original axis [d,e,f] = arbitrary orthogonal axis (cannot be [0,0,0]) a*d + b*e + c*f = 0 

For example, if your original axis is [2,3,4] , you decide:

 2 * d + 3 * e + 4 * f = 0 

That is, any value of [d,e,f] that satisfies this is a satisfactory orthogonal vector (as long as it is not [0,0,0] ). You can select, for example, [3,-2,0] :

 2 * 3 + 3 *-2 + 4 * 0 = 0 6 + -6 + 0 = 0 

As you can see, one “formula” that works is [d,e,f] = [b,-a,0] ... but there are many others that can work; in fact there is infinite!

Once you find the two axes [a,b,c] and [d,e,f] , you can reduce it to the previous case (case 3) using [a,b,c] and [d,e,f] as the x and y axes (or any axes you need to be for your specific problem).


Normalization

Note that as you constantly make point products and cross products, your vectors will start to grow more and more. Depending on what you want, this may not be desirable. For example, you might want your base vectors (your coordinate axes) to be the same size / length.

To turn any vector (except [0,0,0] ) into a unit vector (a vector of length 1, in the same direction as the original vector):

 r = [a,b,c] v = Sqrt(a^2 + b^2 + c^2) <-- this is the length of the original vector r' = [ a/v , b/v , c/v ] 

Where r' is a unit vector r is a vector with a length of 1 that points in the same direction as r . Example:

 r = [1,2,3] v = Sqrt(1^2 + 2^2 + 3^2) = Sqrt(13) = 3.60555 <-- this is the length of the original vector r' = [0.27735, 0.55470, 0.83205] 

Now, if I wanted, for example, a vector in the same direction r with a length of 5, I would simply propagate r' * 5 , which is [a' * 5, b' * 5, c' * 5] .

+16
source share

It is not enough to have only one axis, since there are an infinite number of axes that can be in a perpendicular plane.

If you manage to get another axis, you can use the cross-product to find the third.

+3
source share

If you have one vector (x, y, z), you can get one perpendicular vector for it as (y, -x, 0) (point product xy-yx + 0 * z = 0)

Then you take the cross product of both to get the remaining perpendicular vector: (x, y, z) × (y, -x, 0) = (0y + zx, ​​yz-0x, -x²-y²) = (zx, yz, -x²-y²)

+1
source share

Are you talking about a typical three-coordinate system like the one used in the 3D engine?

With just a vector, you cannot find the other two, the only information you have will be on the plane on which they lie. But they can be at any angle, if they are perpendicular to only one vector, you are.

0
source share

All Articles