Main
2010-04-25 11:42:04
{*********************************************************************************
function RestrictLine(Xi, Yi, Xc, Yc, Slope: Integer; RS, Top: Boolean): Boolean;
By: Main_Ftw, i luffs yeww
Description: Check if a point has passed a line.
Xi, Yi: Imput X and Y value.
Xc, Yc: Center of the line, the origin: Mmcx, Mmcy...etc
Slope: slope of the line, 0 to 1000.
Rs: Are you using it in runescape? This take cares of the inverted rs coordinate.
Top: Is the restricted area Above or under the line.
Example:
Top:=true;
|-Restricted/-----|
|--------------/------|
|-------------/-------|
|------------/--------|
|-----------/---------|
|----------/----------|
|---------/-----------|
|--------/------------|
Top:=false;
|------------/---------|
|-----------/----------|
|----------/-----------|
|---------/------------|
|--------/-------------|
|-------/--------------|
|------/---------------|
|-----/-Restricted-|
Example:
RestrictLine(0, 0, 50, 50, 1, true, true):
- This will result in true, because the input point (0,0) is in the restricted
area which is above line with slope of 1 at the point (50,50).
RestrictLine(0, 0, 50, 50, 1, true, false):
- This will result iin true, because the input point (0,0) is not in the restricted
area which is below line with slope of 1 at the point (50,50).
**********************************************************************************}
function RestrictLine(Xi, Yi, Xc, Yc, Slope: Integer; RS, Top: Boolean): Boolean;
var
Y: Integer;
begin
Y := -1 * slope * (Xi - Xc) + Yc;
if(Top)then
Result := not(Yi > Y)
else
Result := not(Yi < Y);
if(RS)then
Result := not(Result);
end;This work similar to Rs_OnMiniMap, except it makes sure if a point is above (top=false) or under (top=true) a line.

I couldn't find a function like this the other day, so I made one. Please tell me if this is already made.
*Note*
(1) Watch out for the compass, because slope of a line at 60 degree is same as -120 degrees.
(2) It takes care of rs's inverted y axis. The function's line is draw in regular cartesian coordinate, so set rs to true to take care of the point in rs's coordinate system.