0

I need to find angle between two line in my c# program. Can someone help me to calculate the points if only start end poinst given.

enter image description here for line L1 starting point(X1,Y1) and End point (X2,Y2) Given same as for L2 also

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
user3605200
  • 11
  • 1
  • 1
  • 1
    Look up "dot product". You can easily calculate the cosine of the angle knowing a minimum about vectors. – duffymo Jun 04 '16 at 19:39

1 Answers1

3

First, you need to get the two vectors v1 and v2 the two lines and normalize them to the length of 1. Then,

angle = acos(v1•v2)

where: • = 'dot' product and acos = inverse of cosine.

But be aware, there are always two possible results: a1 and a2 where a1+a2 = 180°

derpirscher
  • 14,418
  • 3
  • 18
  • 35