MathGroup Archive 2006

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

Search the Archive

Re: Beginner Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66592] Re: Beginner Question
  • From: Juerg Tschumi <abc at jatabit.ch>
  • Date: Sun, 21 May 2006 00:29:46 -0400 (EDT)
  • References: <e4mmb8$6iu$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hello akil

akil wrote:
> 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.

Complete your 2D points to 3D (0 for the third dimension) and build the 
vector cross product of B-A and C-A. If the third component of the 
resulting vector is >0 (first and second are 0) C lies to the left of 
the line throgh AB, if =0 on the line through AB and if <0 to the right 
of the line through AB (as seen with respect to the direction from A to 
B). ("right hand rule" applied for the vector cross product.)

In[1]:=
a = {ax,ay,0};
b = {bx,by,0};
c ={cx,cy,0};
In[4]:=
Cross[b-a,c-a]
Out[4]=
{0,0,-ay bx+ax by+ay cx-by cx-ax cy+bx cy}

Jürg Tschumi


  • Prev by Date: RE: Beginner Question
  • Next by Date: Re: Mathlink and Intel C++ compiler
  • Previous by thread: RE: Beginner Question
  • Next by thread: Re: Beginner Question