How to calculate the angle of a line passing by 2 points

Code:

Angle_Line 0.0,0.0, 0.0,150.0

sub Angle_Line (xDeb as double, yDeb as double, xFin as double, yFin as double)

Dim Tangeante, Angle_Rad As Double

Dim pI As Double

'PI = 4 * Atn(1)

pI = 3.1459265359

If (xFin - xDeb) = 0 Then GoTo Verti:

Tangeante = (yFin - yDeb) / (xFin - xDeb)

Angle_Rad = Atn(Tangeante)

Angle_Ligne = Angle_Rad * 57.29577951308 '(180 / pI)

GoTo Fin_ANGLE_LIGNE:

Verti:

If (yFin - yDeb) > 0 Then Angle_Ligne = 90

If (yFin - yDeb) < 0 Then Angle_Ligne = -90

Fin_ANGLE_LIGNE:

print Angle_Ligne

End sub

sub Angle_Line (xDeb as double, yDeb as double, xFin as double, yFin as double)

Dim Tangeante, Angle_Rad As Double

Dim pI As Double

'PI = 4 * Atn(1)

pI = 3.1459265359

If (xFin - xDeb) = 0 Then GoTo Verti:

Tangeante = (yFin - yDeb) / (xFin - xDeb)

Angle_Rad = Atn(Tangeante)

Angle_Ligne = Angle_Rad * 57.29577951308 '(180 / pI)

GoTo Fin_ANGLE_LIGNE:

Verti:

If (yFin - yDeb) > 0 Then Angle_Ligne = 90

If (yFin - yDeb) < 0 Then Angle_Ligne = -90

Fin_ANGLE_LIGNE:

print Angle_Ligne

End sub

How to calculate intersection of 2 lines

giving 2 points for the first line and 2 points for the second line return the intersection point in X1 and Y1

Code:

line_intersect 0.0,0.0,100,100,0,15,100,15

Sub Line_intersect (Xdeb1 as double, Ydeb1 as double, Xfin1 as double, Yfin1 as double, Xdeb2 as double, Ydeb2 as double, Xfin2 as double, Yfin2 as double)

XA = Xdeb1

YA = Ydeb1

XB = Xfin1

YB = Yfin1

XC = Xdeb2

YC = Ydeb2

XD = Xfin2

YD = Yfin2

UP = YD - YC

VP = XC - XD

WP = (YC * XD) - (XC * YD)

U = YB - YA

V = XA - XB

W = (YA * XB) - (XA * YB)

X1 = ((V * WP) - (VP * W)) / ((U * VP) - (UP * V))

Y1 = ((W * UP) - (WP * U)) / ((U * VP) - (UP * V))

Intersection_X = X1

Intersection_Y = Y1

print x1,y1

end sub