[Tutor] Calculating Deflection angles

Terry Carroll carroll at tjc.com
Wed Jul 4 17:40:08 CEST 2007


On Wed, 4 Jul 2007, nitin chandra wrote:

> Hello Every One,
> 
> I create a list of coordinates of 2 lines.
> X11,Y11 & X12,Y12 as starting and ending of one line.
> X21,Y21 & X22, Y22 as starting and ending of the 2nd line.
> 
> Now is there any way to calculate the deflection angle between the two
> lines? Will any modules be required other than Python 2.3 (on Linux)?

I'm looking at my old book "A Programmer's Geometry" now.

If you first put the equations for each line in the AX+BY+C=0 form, i.e.,

 Line 1:  A1*X + B1*Y + C1 = 0
 Line 2:  A2*X + B2*Y + C2 = 0

Then the angle between them is found by:

theta = acos(
             (A1*A2 + B1*B2) 
           /
           sqrt((A1**2+B1**2)*(A2**2+B2**2))
           )



More information about the Tutor mailing list