Re: Beginner Question

• To: mathgroup at smc.vnet.net
• Subject: [mg66587] Re: Beginner Question
• From: "Scout" <Scout at nodomain.com>
• Date: Sun, 21 May 2006 00:29:29 -0400 (EDT)
• References: <e4mmb8\$6iu\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```"akil" <akil39 at gmail.com>
news:e4mmb8\$6iu\$1 at smc.vnet.net...
> 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.
>

Well, the Dot Product can do better the work.
Below it's a simple procedure:

In[1]:= point2DQ[x_] := VectorQ[x] && (Length[x] == 2);

Now, we can write the function that will decide on the A,B,C  points:

In[2]:= whichPart[a_?point2DQ, b_?point2DQ, c_?point2DQ] :=
Module[{v1 = c - a, v2 = b - a},
(v1 . v2) / (Norm[v1]*Norm[v2])
];

If the whichPart[] function gives a negative number (< 0), then the C point
is on the right if you move from A to B;
if it gives a positive number (> 0), then the C point is on the left if you
move always from A to B;
and if it equals 1, then the 3 points are on the same line.

Best,
~Scout~

```

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