Re: Math help.
Re: Math help.
- Subject: Re: Math help.
- From: Emmanuel <email@hidden>
- Date: Fri, 16 Feb 2001 07:47:09 +0100
At 2:47 +0100 16/02/01, Brad Giesbrecht wrote:
>
Hello list,
>
>
Can I get right at it?
>
>
Ok, I have grid coordinate's that make up a rectangle
>
and a center.
>
>
Now, what is the argument to determine if
>
this_item {x, y} coordinate's fall in top_area,
>
right_area, bottom_area, or left_area.
You need test whether this_item is "above" or "below" each of the two
diagonals.
Two aboves -> top_area, above first and below second -> right_area etc.
To test whether a given (x,y) is above or below the line joining two given
points (x1,y1) and (x2,y2), compute:
(y-y1)-(x-x1)*(y2-y1)/(x2-x1)
If this is > 0 (for instance, for x=0 and y very large) then (x,y) is above.
If this is < 0 (for instance, for x=0 and y very negative) then (x,y) is below.
HTH
Emmanuel
References: | |
| >Math help. (From: Brad Giesbrecht <email@hidden>) |