Trig Question

If you have 3 points on a cartesian definining 2 lines with a shared endpoint, how do you find the number of degrees between the two lines?

PointA and PointB is Line1
PointB and PointC is Line2

Help please.

Let’s say you have a triangle with lengths a, b, and c. The angle opposite c is C.

c[sup]2[/sup] = a[sup]2[/sup] + b[sup]2[/sup] - 2(a)(b)(cos C)

Then solve for C.

So you have to figure out the lengths first?

180 - arctan(absval(yB-yA)/(xB-xA)) - arctan(absval(yB-yC)/(xB-xC))

What you are doing is finding the angles of the other 2 sides of the triangle and subtracting them from 180.

Yea, but that’s easy enough. Use Pythagorean’s Theorem.

Another way of stating Crafter_Man’s answer is as follows. The dot product of two vectors v[sub]1[/sub] and v[sub]2[/sub] is defined as v[sub]1[/sub].v[sub]2[/sub] = v[sub]1[/sub]v[sub]2[/sub]cos W where v[sub]1[/sub] and v[sub]2[/sub] are the magnitudes (lengths) of the vectors and W is the angle between. Given the three points A(x[sub]a[/sub],y[sub]a[/sub]), B(x[sub]b[/sub],y[sub]b[/sub]), C(x[sub]c[/sub],y[sub]c[/sub]) and defining the vectors v[sub]1[/sub] as (x[sub]b[/sub]-x[sub]a[/sub], y[sub]b[/sub]-y[sub]a[/sub]) and v[sub]2[/sub] as (x[sub]b[/sub]-x[sub]c[/sub],y[sub]b[/sub]-y[sub]c[/sub]), then:

if D = (x[sub]b[/sub]-x[sub]a[/sub])(x[sub]b[/sub] - x[sub]c[/sub]) + (y[sub]b[/sub]-y[sub]a[/sub])(y[sub]b[/sub]-y[sub]c[/sub])

and N = sqr{(x[sub]b[/sub]-x[sub]a[/sub])^2+(y[sub]b[/sub]-y[sub]a[/sub])^2}sqr{(x[sub]b[/sub]-x[sub]c[/sub])^2+(y[sub]b[/sub]-y[sub]c[/sub])^2}

then cosW = D/N and W = cos[sup]-1/sup

Easy, wasn’t it!

so the angle I’m looking for is
angle = 180 - arctan(absval(yB-yA)/(xB-xA)) - arctan(absval(yB-yC)/(xB-xC))




and N = sqr{(xb-xa)^2+(yb-ya)^2}sqr{(xb-xc)^2+(yb-yc)^2}

what does the { } mean? same as () ? so that would be sqr(etc)*sqr(etc)


Yes, the curly braces are there just to try to keep clear the groupings… I was also starting to suffer from square bracket overload doing all that vbCoding. The magnitude of a vector is calculated using the square root of the sum of the squares of the x and y components as usual, the denominator of the expression is the product of the two magnitudes. It’s not a pretty formula, but if all you are given is the coordinates of the three points, it’s the most straight forward one I could dredge up from memory. Like all such formulae, calculating the angle requires performing an inverse trig function at some point. However, most all scientific calculators ahve these built in… {not like the good old days of slide rules and trig tables like when I was a wee shrubbery}

BioHazard, some math teachers like to play with words to help their students remember a math formula. Given two points on the Cartesian plane, the distance between them is “the square root of the square of the sums of the differences”. My trig teacher liked to run this phrase by us as often as he could…
Or, in other words: D = ((x1-x0)^2 + (y1-y0)^2)^0.5

Oops! It SHOULD read as : “square root of the sum of the squares of the differences” - Jinx

Thanks guys!

I’m only a little dizzy right now…

falls down