Define a procedure perpDist(px, py, a, b, c)
that returns the unsigned (positive) distance between a point in two-dimensional space with coordinates px, py
and a line with equation ax + by + c == 0
. Use math.sqrt
(of type num -> float). Your function should have type (num, num, num, num, num) -> float
.
import math
def perpDist(px, py, a, b, c):
return abs(a * px + b * py + c) / math.sqrt(a*a + b*b)