Chris,

I got it to work, solution is below. Thanks for all your help... sympy rocks!!!.

Cathal

import sympy
from sympy import Rational

# Convert to Rational
def rat(d):
    return Rational(str(d))

# Calculate the perpendicular distance from the point (lat, lon) to
the line defined by the points (x1, y1) and (x2, y2).
def perpendicular_distance(x1, y1, x2, y2, lat, lon):
    p1 = sympy.geometry.Point(self.rat(x1), self.rat(y1))
    p2 = sympy.geometry.Point(self.rat(x2), self.rat(y2))
    l = sympy.geometry.Line(p1,p2)
    p = sympy.geometry.Point(self.rat(lat), self.rat(lon))

    s = l.perpendicular_segment(p)
    return s.length.n()

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to