Hello,

I wasn't sure where to post this, so please feel free to move it. In some ways, I suspect this is a very elementary question for an expert, so I posted in on the pre-university side.

Here is an example in 2D of the problem I am looking at,

given three sets of coordinates, calculate the angle ABC.

In 2D, I assume I would start with something like,

mAB = 0.08-0.31/0.07-0.56

mAB = 0.46939

mAC = 0.86-0.31/0.49-0.56

mAC = -7.85714

tan Ɵ = (0.46939- -7.85714)/(1+0.46939*-7.85714)

tan Ɵ = -3.09759

arctan -3.09759 = -1.258526901 radians = -72.11 degrees

...you don't have to be a geometry expert to see that isn't right for the data in the plot as ABC is obviously >90.

Further, I need to do this in high dimensional space, so the equations I use need to be for cases other than x,y. I don't have access to Matlab, but I could program something in c++ with the Eigen library.

My understanding of this problem in higher dimensions is that the lines AB and AC are vectors. Assuming that the n-space is orthogonal (which it is in this case), the vectors AB and AC lie in a Euclidean plane and so I would need to derive the vectors AB and AC from the coordinates and then derive the angle between.

This website,

Online calculator. Angle between vectors.

calculates the angle between two vectors based on the start and end point coordinates of the vector (in 2D or 3D). This is the output of the solver for my points in 2D,

Calculate vector by initial and terminal points:

AB = {Bx - Ax; By - Ay} = {0.07 - 0.56; 0.08 - 0.31} = {-0.49; -0.23}

CD = {Dx - Cx; Dy - Cy} = {0.49 - 0.56; 0.86 - 0.31} = {-0.07; 0.55}

Calculate dot product:

AB

Calculate magnitude of the vectors:

|AB| = √AB

|CD| = √CD

Calculate angle between vectors:

cos α = AB

cos α = -461/5000 / √2930/100

This method give yet a different answer which is also obviously not correct where I would estimate the angle to be ~100 degrees. The vector method is preferable in that I think I can see how to expand this to any dimension.

Can someone please let me know what I am doing wrong here?

I wasn't sure where to post this, so please feel free to move it. In some ways, I suspect this is a very elementary question for an expert, so I posted in on the pre-university side.

Here is an example in 2D of the problem I am looking at,

given three sets of coordinates, calculate the angle ABC.

In 2D, I assume I would start with something like,

**Find the slope of AB and AC, m=y2-y1/x2-x1**mAB = 0.08-0.31/0.07-0.56

mAB = 0.46939

mAC = 0.86-0.31/0.49-0.56

mAC = -7.85714

**Find the tangent of the angle, tan Ɵ = (mAB-mAC) / (1+mAB*mAC)**tan Ɵ = (0.46939- -7.85714)/(1+0.46939*-7.85714)

tan Ɵ = -3.09759

**Find the arctan and convert to degrees,**arctan -3.09759 = -1.258526901 radians = -72.11 degrees

...you don't have to be a geometry expert to see that isn't right for the data in the plot as ABC is obviously >90.

Further, I need to do this in high dimensional space, so the equations I use need to be for cases other than x,y. I don't have access to Matlab, but I could program something in c++ with the Eigen library.

My understanding of this problem in higher dimensions is that the lines AB and AC are vectors. Assuming that the n-space is orthogonal (which it is in this case), the vectors AB and AC lie in a Euclidean plane and so I would need to derive the vectors AB and AC from the coordinates and then derive the angle between.

This website,

Online calculator. Angle between vectors.

calculates the angle between two vectors based on the start and end point coordinates of the vector (in 2D or 3D). This is the output of the solver for my points in 2D,

Calculate vector by initial and terminal points:

AB = {Bx - Ax; By - Ay} = {0.07 - 0.56; 0.08 - 0.31} = {-0.49; -0.23}

CD = {Dx - Cx; Dy - Cy} = {0.49 - 0.56; 0.86 - 0.31} = {-0.07; 0.55}

Calculate dot product:

AB

**·**CD = AB_{x}**·**CD_{x}+ AB_{y}**·**CD_{y}= (-0.49)**·**(-0.07) + (-0.23)**·**0.55 = 0.0343 - 0.1265 = -4615000Calculate magnitude of the vectors:

|AB| = √AB

_{x}^{2}+ AB_{y}^{2}= √(-0.49)^{2}+ (-0.23)^{2}= √0.2401 + 0.0529 = √0.293 = √2930100|CD| = √CD

_{x}^{2}+ CD_{y}^{2}= √(-0.07)^{2}+ (0.55)^{2}= √0.0049 + 0.3025 = √0.3074 = √3074100Calculate angle between vectors:

cos α = AB

**·**CD / |AB||CD|cos α = -461/5000 / √2930/100

**·**√3074/10 = -461√22517052251705 ≈**-0.3072169542860648**This method give yet a different answer which is also obviously not correct where I would estimate the angle to be ~100 degrees. The vector method is preferable in that I think I can see how to expand this to any dimension.

Can someone please let me know what I am doing wrong here?

**LMHmedchem**
Last edited: