# left or right in coordinate space

• Oct 7th 2009, 05:42 AM
left or right in coordinate space
Hi all.
Im new to the forum, and came across it on the hunt for some maths brains better than mine. I'm a hobbyist programmer and have hit a barrier. Eternally grateful if you can help.

In the diagram there are two points creating a line in a coordinate space. This is for Flash, so the origins of x and y are in the top left corner, but hopefully this shoudn't matter. When point B moves, I get a third point (C). I need a reliable method for determining whether point B has moved left or right of the original line. All I know are the coordinates for the two orginal points and the new position of A.

I'm happy with finding distances between points, angles etc - it's the application in this context I'm finding tricky.

If anyone has an idea of where might I start with this, I'd be grateful.

Many thanks.
• Oct 7th 2009, 06:16 AM
HallsofIvy
You will need to know the coordinates of two points on the line separating "left" and "right". It appears that a and b are initially on that line so save those coordinates as, say $(x_1, y_1)$ and $(x_2, y_2)$. Then the equation of that line is $y= \frac{y_2- y_1}{x_2- x_1}(x- x_1)+ y_1$ or, equivalently, $y- \frac{y_2- y_1}{x_2- x_1}(x- x_1)- y_1= 0$. Points to the left of that line will have $y- \frac{y_2- y_1}{x_2- x_1}(x- x_1)- y_1< 0$, points to the right will have $y- \frac{y_2- y_1}{x_2- x_1}(x- x_1)- y_1> 0$.

That is, to determine whether a point is left or right of that line, calculate $y- \frac{y_2- y_1}{x_2- x_1}(x- x_1)- y_1$ and see if it is positive or negative.
• Oct 7th 2009, 06:52 AM