[Tutor] Questions of Maths

Andre Roberge andre.roberge at gmail.com
Wed Apr 18 14:51:55 CEST 2007

On 4/18/07, Abu Ismail <abdulhafid at gmail.com> wrote:
> Hi,
> I am working on an implementation of an L-system in Python. I hate
> using turtle module since it uses Tk and as my IDE also uses Tk I have
> to close my editor before I can test the program. So I am implementing
> the graphics using PIL.
> Now to the problem.
> Say you have a line AB with co-ords (x1,y1) and (x2,y2). Say you also
> have a point C with co-ords (x3,y3).
> Question: how to determine whether point C is to the left or to the
> right of the line AB?
1. Write an equation for the line AB in the form x = Wy + Z  (as
opposed to y = mx + b, which is the usual form).
2. Substitute the value for y3 in that equation - it will give you the
value of x on that line (call it X3).
3. Compare x3 with X3.

A quick derivation gave me (please verify)
x = [(x2-x1) y + x1 y2 - x2 y1]/(y2-y1)
where the multiplication signs are implicit.

Good luck!


> Any suggestions would be welcome.
> Ta,
> AH
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list