Find XYZ for Tip of Vector Given Info on 2 Other Vectors w/ Tails at Same Point

In summary, the data set has a centroid at the origin, and the point at which the three vectors intersect is the rotated centroid.
  • #1
LMHmedchem
20
0
I have posted this in University linear algebra, but it is possible there is a simple answer for this and the the problem belongs in some other forum. I apologize if that is the case.

I am starting with 3 points in 3 space, along with the centroid of the full data set. The data is in principle components so the centroid is at the origin (within floating point variance). I am rotating that data to new coordinates according to the following method.

I create 3 vectors by taking the difference between each point and the centroid using, the standard formula for creating a vector between two points.

vx = xdest - xsrc
vy = ydest - ysrc
vz = zdest - zsrc
...
vn = ndest - nsrc

Below, "point 1" refers to the point in the original coordinates and "point A" refers to the same point in the rotated coordinate system.

To generate the rotated coordinates:

1. Call the origin point O, 0,0,0

2. Place the point 1 vector along the x-axis with the tail of the vector at the origin and the tip at the magnitude of the vector between the centroid and point 1. This forms vector OA where the y and z values of point A are arbitrarily set to 0 and the x-axis value is |OA|.

3. Place the point 2 vector in the xy-plane. This forms the vector OB with the tail at the origin and point B with x,y coordinates determined as,

Bx = Ox + d*cos(AOB)
By = Oy + d*sin(AOB)

where Ox, Oy is the tail of the vector at the origin, d is the magnitude of OB, and AOB is the angle between OA and OB (angle determined from vectors placed in the original coordinates). Since point B is arbitrarily in the xy plane, the z coordinate value is set to 0.0.

4. Place the point 3 vector with the tail at the origin and the tip at point C. This point will have some values of x,y, and z. Since there will be two possible solutions for the z value of point C, we will keep this right handed and assign the z coordinate as positive.

Where I am stuck is how I am to determine the x,y,z coordinates of the point C.

Here is a specific example from my data.

Code:
[B]row[/B]        [B]x[/B]               [B]y[/B]                [B]z[/B]
centroid   0.00000012977   0.00000001496   -0.00000001033
point_1   -5.63359         1.92305          0.274911
point_2   -2.87059        -0.492249         0.178748
point_3   -5.63085         1.57711          0.360911

point 1 becomes vector OA (from origin to point A)
vector OA is along the x-axis (y=0, z=0)
call the tip of vector OA point A
vector magnitude = 5.95911
coordinates: 5.95911, 0, 0

point 2 becomes vector OB (from origin to point B)
vector OB is in the xy plane (z=0)
call the tip of vector OB point B
vector magnitude = 2.90191
angle AOB = 148.77 (degrees), 2.59652 (radians)
coordinates: -2.4814, 5.4179, 0

point 3 becomes vector OC (from origin to point C)
I know the following about vector OC,
1. magnitude = 5.85867
2. angle AOC = 3.31715 (degrees), 0.0578952 (radians)
3. angle BOC = 152.013 (degrees), 2.65313 (radians)
4. The plane of angle AOB intersects with the plane of angle AOC along OA (the x-axis). The angle at which these planes intersect is 12.7435 (degrees), 0.2224160332 (radians).

It seems as if there should be more then enough information here, but I haven't found a formula and I can't seem to quite parse it out. I have not found the 3d equivalent of the formula used to calculate the x and y values for point B.

Since I know the angle at which the AOB and AOC planes intersect, my thought was to use the formulas used to determine x,y for point B to place a point in the xz plane and set y = 0. This would give me a new vector OD, with the magnitude of OC and the correct x and z coordinates for OC (I think).

Since AOB is in the xy plane and the new vector AOD is in the xz plane, the angle of the AOB AOD plane intersection is 90 degrees. This would meant that the angle between the vector OC (the vector I am solving for) and OD would be the difference between 90 (AOB AOD plane intersection angle) and the AOB AOC plane intersection angle. That would be angle COD = 90 - 12.7435 = 77.2565 (degrees), 1.348380294 (radians).

It seem like I should be able to use that information to determine the y-axis value as,

Cy = Oy + dOC*sin(COD), COD in radians

meaning that the y-axis value of point C would be 0 + the magnitude of OC times the sine of the angle COD.

I guess I am trying to swing the vector OD in the xz plane to the known plane intersection angle. I'm not sure if this changes the just the y-axis value or if I also need to calculate a new x, or if I am thinking about this in any way that is at all reasonable.

My guess is that there is a straightforward formula for this and I just don't know the proper search terms to find it. I would like a clearer understating of the relationships here as well. Formulas are nice, but you can get in plenty of trouble applying them if you don't fully understand the theory.

Thanks for the help if you have time. Please let me know if there is anything that needs to be clarified. I could post data for a 3d R plot if that would help. Let me know.

LMHmedchem
 
Last edited:
Physics news on Phys.org
  • #2
Hi LMHmedchem, welcome to MHB!

Let's call point 1 $\mathbf p_1$, point 2 $\mathbf p_2$, and so on.
And let's call the centroid $\mathbf m$.

Now let's first subtract the centroid from all points.
So:
$$\mathbf q_1 = \mathbf p_1 - \mathbf m, \quad \mathbf q_2 = \mathbf p_2 - \mathbf m, \quad ...$$
That would mean that all the new arrows have their tail at the origin yes?

That leaves rotating them such that $\mathbf q_1$ becomes aligned with the x-axis, and $\mathbf q_2$ becomes a vector in the XY-plane.
That's what you want isn't it?

It means that we're looking for a matrix $A$ such that:
$$A\mathbf q_1 = \| \mathbf q_1 \| \mathbf{\hat x}$$
where $\| \mathbf q_1 \|$ is the length of $\mathbf q_1$, and $\mathbf{\hat x}$ is the vector of unit length along the x-axis.

Let's define:
$$\mathbf a = \frac{\mathbf q_1}{\| \mathbf q_1 \|} \\
\mathbf c = \frac{\mathbf q_1 \times \mathbf q_2}{\| \mathbf q_1 \times \mathbf q_2 \|} \\
\mathbf b = \mathbf c \times \mathbf a
$$
where $\times$ denotes the so called cross product.
This forms an orthogonal basis, which is what we want to rotate such that it becomes aligned with the respective coordinate axes.

Then we need that:
$$A( \mathbf a,\ \mathbf b,\ \mathbf c) = (\mathbf{\hat x},\ \mathbf{\hat y},\ \mathbf{\hat z})
$$
where $( \mathbf a,\ \mathbf b,\ \mathbf c)$ is the matrix formed by the respective vectors as its columns, and $(\mathbf{\hat x}, \mathbf{\hat y}, \mathbf{\hat z})$ is the matrix of the unit vectors along each of the respective axes (the identity matrix).

Find the matrix inverse $A=( \mathbf a,\ \mathbf b,\ \mathbf c)^{-1}$ and... we're done.

The transformation you're looking for is:
$$\mathbf p_i' = A(\mathbf p_i - \mathbf m)$$
 
Last edited:
  • #3
Thank you for the informative post. Sorry for the delay in replying, I really haven't learned latex very well and so I had to slog around a bit with an interpreter. I actually learned trigonometry at a time when if you wanted to know the cosine of a number, you looked it up in a huge book of trigonometric tables that got passed around the classroom. I suppose every 4th grader knows latex now.

I like Serena said:
Let's call point 1 $\mathbf p_1$, point 2 $\mathbf p_2$, and so on.
And let's call the centroid $\mathbf m$.

Now let's first subtract the centroid from all points.
So:
$$\mathbf q_1 = \mathbf p_1 - \mathbf m, \quad \mathbf q_2 = \mathbf p_2 - \mathbf m, \quad ...$$
That would mean that all the new arrows have their tail at the origin yes?

This is the method I used with my standard c++ function for vector_between_points().

Starting with my example of p1, p2, p3,
Code:
row        x               y                z
centroid   0.00000012977   0.00000001496   -0.00000001033
point_1   -5.63359         1.92305          0.274911
point_2   -2.87059        -0.492249         0.178748
point_3   -5.63085         1.57711          0.360911

I get the following for q1, q2, q3,

Code:
row    x          y          z
q1    -0.71899   -0.40753    0.7495
q2     0.04617    0.75916    0.34083
q3   -11.41928   -3.04078   12.97502

I like Serena said:
That leaves rotating them such that $\mathbf q_1$ becomes aligned with the x-axis, and $\mathbf q_2$ becomes a vector in the XY-plane.
That's what you want isn't it?

Yes, that is what I am looking for.

I like Serena said:
It means that we're looking for a matrix $A$ such that:
$$A\mathbf q_1 = \| \mathbf q_1 \| \mathbf{\hat x}$$
where $\| \mathbf q_1 \|$ is the length of $\mathbf q_1$, and $\mathbf{\hat x}$ is the vector of unit length along the x-axis.

Let's define:
$$\mathbf a = \frac{\mathbf q_1}{\| \mathbf q_1 \|} \\
\mathbf c = \frac{\mathbf q_1 \times \mathbf q_2}{\| \mathbf q_1 \times \mathbf q_2 \|} \\
\mathbf b = \mathbf c \times \mathbf b
$$
where $\times$ denotes the so called cross product.
This forms an orthogonal basis, which is what we want to rotate such that it becomes aligned with the respective coordinate axes.

Then we need that:
$$A( \mathbf a,\ \mathbf b,\ \mathbf c) = (\mathbf{\hat x},\ \mathbf{\hat y},\ \mathbf{\hat z})
$$
where $( \mathbf a,\ \mathbf b,\ \mathbf c)$ is the matrix formed by the respective vectors as its columns, and $(\mathbf{\hat x}, \mathbf{\hat y}, \mathbf{\hat z})$ is the matrix of the unit vectors along each of the respective axes (the identity matrix).

Find the matrix inverse $A^{-1}=( \mathbf a,\ \mathbf b,\ \mathbf c)^{-1}$ and... we're done.

Using an online matrix inverse calculator,
Reshish Matrix Calculator

For the matrix,
Code:
      A1         A2         A3
1    -0.71899   -0.40753    0.7495
2     0.04617    0.75916    0.34083
3   -11.41928   -3.04078   12.97502

I get the inversion $$A^{-1}$$,
Code:
     B1         B2         B3
1    27.5467    7.6129    -1.7912
2   -11.3640   -1.9488     0.7076
3    21.5805    6.2434    -1.3335
I like Serena said:
The transformation you're looking for is:
$$\mathbf p_i' = A^{-1}(\mathbf p_i - \mathbf m)$$

If I understand this, to get each p prime (point p rotated into the new coordinate system), I multiply each element of q (or p-m) by the inverse of A, $$A^{-1}$$. Do you mean here to multiply the matrix point q by the inverse of A? I know that the coordinates for point q1 must be 5.6336,0,0 and I can't get any version of what I just described to give those results, so I must not have this right.

LMHmedchem
 
Last edited:
  • #4
LMHmedchem said:
Thank you for the informative post. Sorry for the delay in replying, I really haven't learned latex very well and so I had to slog around a bit with an interpreter. I actually learned trigonometry at a time when if you wanted to know the cosine of a number, you looked it up in a huge book of trigonometric tables that got passed around the classroom. I suppose every 4th grader knows latex now.

No worries. 4th graders don't know it.
Most people only learn (slowly at first) when they become active on forums such as this one. :)

LMHmedchem said:
This is the method I used with my standard c++ function for vector_between_points().

Starting with my example of p1, p2, p3,
Code:
row        x               y                z
centroid   0.00000012977   0.00000001496   -0.00000001033
point_1   -5.63359         1.92305          0.274911
point_2   -2.87059        -0.492249         0.178748
point_3   -5.63085         1.57711          0.360911

I get the following for q1, q2, q3...

Let's redo that.
We start with:
$$
\mathbf m = \begin{pmatrix}0.00000012977 \\ 0.00000001496 \\ -0.00000001033 \end{pmatrix},
\mathbf p_1 = \begin{pmatrix} -5.63359 \\ 1.92305 \\ 0.274911 \end{pmatrix},
\mathbf p_2 = \begin{pmatrix} -2.87059 \\ -0.492249 \\ 0.178748 \end{pmatrix},
\mathbf p_3 = \begin{pmatrix} -5.63085 \\ 1.57711 \\ 0.360911 \end{pmatrix}
$$
Then we do $\mathbf q_1 = \mathbf p_1 - \mathbf m$ and so on:
$$
\mathbf q_1 = \begin{pmatrix} -5.63359013 \\ 1.923049985 \\ 0.27491101 \end{pmatrix},
\mathbf q_2 = \begin{pmatrix} -2.87059013 \\ -0.492249015 \\ 0.17874801 \end{pmatrix},
\mathbf q_3 = \begin{pmatrix} -5.63085013 \\ 1.577109985 \\ 0.36091101 \end{pmatrix}
$$
Find the cross product of $\mathbf q_1$ and $\mathbf q_2$:
$$\mathbf q_1 \times \mathbf q_2 = \begin{pmatrix} 0.479066033 \\ 0.217836194 \\ 8.293417498 \end{pmatrix}$$

Then:
$$
\mathbf a = \frac{\mathbf q_1}{\| \mathbf q_1 \|}
= \begin{pmatrix} -0.945373842 \\ 0.322707387 \\ 0.046132869 \end{pmatrix}\\
\mathbf c = \frac{\mathbf q_1 \times \mathbf q_2}{\| \mathbf q_1 \times \mathbf q_2 \|}
= \begin{pmatrix} 0.057648661 \\ 0.026213432 \\ 0.997992729 \end{pmatrix}\\
\mathbf b = \mathbf c \times \mathbf a
= \begin{pmatrix} -0.320850325 \\ -0.946135719 \\ 0.043385142 \end{pmatrix}
$$

Now the matrix inverse:
$$
A = (\mathbf a, \mathbf b, \mathbf c)^{-1}
= \begin{bmatrix}
-0.945373842 & -0.320850325 & 0.057648661 \\
0.322707387 & -0.946135719 & 0.026213432 \\
0.046132869 & 0.043385142 & 0.997992729 \\
\end{bmatrix}^{-1}
= \begin{bmatrix}
-0.945373842 & 0.322707387 & 0.046132869 \\
-0.320850325 & -0.946135719 & 0.043385142 \\
0.057648661 & 0.026213432 & 0.997992729 \\
\end{bmatrix}
$$

And finally find the images:
$$
\mathbf p_1' = A\mathbf q_1 = \begin{pmatrix} 5.959113614 \\ 0 \\ 0 \end{pmatrix},
\mathbf p_2' = \begin{pmatrix} 2.563174584 \\ 1.394519161 \\ 0 \end{pmatrix},
\mathbf p_3' = \begin{pmatrix} 5.848853322 \\ 0.330158183 \\ 0.076917057 \end{pmatrix}
$$
We can see that $\mathbf p_1'$ is now aligned with the x-axis, and $\mathbf p_2'$ is in the XY-plane.
 

1. How do I find the XYZ coordinates for the tip of a vector given information on two other vectors?

To find the XYZ coordinates for the tip of a vector, you will need to use the vector addition and subtraction operations. First, draw out a diagram of the three vectors with their tails at the same point. Then, use the properties of vector addition and subtraction to solve for the unknown vector. This will give you the XYZ coordinates for the tip of the vector.

2. What information do I need in order to solve for the XYZ coordinates in this scenario?

In order to solve for the XYZ coordinates, you will need the magnitudes and directions of the two known vectors, as well as the angle between them. It is also important to know the order in which the vectors are being added or subtracted.

3. Can I use this method to find the XYZ coordinates for any vector?

Yes, this method can be used to find the XYZ coordinates for any vector, as long as you have the necessary information about the other two vectors. However, this method only works when the vectors have their tails at the same point.

4. Is there a way to check my answer for the XYZ coordinates?

Yes, you can check your answer by using the Pythagorean theorem and the trigonometric functions to calculate the magnitude and direction of the unknown vector. If your calculated values match the given information, then your XYZ coordinates are correct.

5. Can I use a calculator or computer program to solve for the XYZ coordinates?

Yes, you can use a calculator or computer program to solve for the XYZ coordinates. Most scientific calculators have functions for vector addition and subtraction, and there are also online calculators and computer programs specifically designed for vector operations.

Similar threads

  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
5
Views
2K
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
958
Replies
3
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
928
  • Linear and Abstract Algebra
Replies
2
Views
2K
  • Linear and Abstract Algebra
Replies
6
Views
2K
  • Precalculus Mathematics Homework Help
Replies
20
Views
2K
Back
Top