For a line, it is a plunge and not a dip (for 3D planes)
It is an elementary problem in analytic geometry:
The distance = SQRT((x2 –x1)2+(y2 –y1)2+(z2 –z1)2)
The plunge = arcsin ((z2 – z1) / distance)
The azimuth = arctan((x2 –x1)/(y2 –y1))
(always in two dimensions)
The value θ
returned will be in the range of ±90°
and must be corrected to give the true azimuth over the range of 0 to 360°
You can also use the direction cosines of the line (the slopes on the xy,
xz
and yz
planes)

In Python:
import math
x1,y1,z1 = 5.0,6.7,1.5
x2,y2,z2 = 4.0,1.2,1.6
distance = math.sqrt((x2-x1)**2+(y2-y1)**2+(z2 -z1)**2)
print distance
5.5910642993977451
plunge = math.degrees(math.asin((z2-z1)/distance)
print plunge
1.0248287567800018 # the resulting dip_plunge is positive downward if z2 > z1
azimuth = math.degrees(math.atan2((x2-x1),(y2-y1)))
print azimuth
-169.69515353123398 # = 360 + azimuth = 190.30484646876602 or 180+ azimuth = 10.304846468766016 over the range of 0 to 360°
With the direction cosines:
cosalpha =(x2-x1)/distance
cosbeta=(y2-y1)/distance
cosgamma= (z2-z1)/distance
plunge = math.degrees(math.asin(cosgamma))
print plunge
1.0248287567800018 # the resulting dip_plunge is positive downward if z2 > z1
azimuth = math.degrees(math.atan2(cosa, cosb))
print azimuth
-169.69515353123398 # = 360 + azimuth = 190.30484646876602 or 180+ azimuth = 10.304846468766016 over the range of 0 to 360°