MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Beginner Question

On 20 May 2006, at 17:47, akil wrote:

> Hi,
> Suppose I have three 2D points A, B, C.
> And two points, namely A and B form a line.
> How can I determine in mathematica on which side, (so which half- 
> plane formed by) of the line, point C is.
> So when I input three points I want to know if the third point is  
> on the left or right side of the half plane formed by the line  
> (ray) A,B.
> Appreciate any help.

One way is simply to work out the (linear) Cartesian equation of the  
line through A,B and then substitute the coordinates of point C into  
the  linear "dual" of the line. Positive answers will correspond to  
point on one side and negative to points on the other. Here is an  
example. Let's consider four points P,Q,R,S as follows:

P = {1, 2}; Q = {3, 4}; R = {-3, 5}; S = {2, -5};

We are going to take the line PQ and determine if R and S are on the  
same or opposite sides of the line. The picture looks like this:

Show[Graphics[{Line[{P, Q}],
      Map[{PointSize[0.03], Point[#]} &, {
         P, Q, R, S}]}], AspectRatio -> Automatic, PlotRange -> All];

Here is how to get the linear function:

linFun = Eliminate[{x, y} == Q + t*(P - Q), t] /.
    Equal -> Subtract

-x + y - 1

Here is how we perform our checks:

linFun /. Thread[{x, y} -> R]


linFun /. Thread[{x, y} -> S]


So the points lie on opposite sides of the line. If you look  
carefully at the above method you can see that positive answers will  
correspond to points lying "to the left and above" and negative  
answers to points to "the right and below".

Andrzej Kozlowski

Tokyo, Japan

  • Prev by Date: Re: Beginner Question
  • Next by Date: RE: Beginner Question
  • Previous by thread: Beginner Question
  • Next by thread: Re: Beginner Question