IsPointInArea - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: IsPointInArea (
/showthread.php?tid=282327)
IsPointInArea -
CaHbKo - 10.09.2011
Hi, I was wondering if it's possible to make a function (or find one), which could check whether a point is in an area of a shape with
n corners, so it'd be universal for checking shapes that are 4+ cornered. It should also work with 3D coordinates. I was doing some research about this and found this formula on Wikipedia
Any volumetric sweep(calculus required) |  | h = any dimension of the figure,A(h) = area of the cross-sections perpendicular to h described as a function of the position along h.a and b are the limits of integration for the volumetric sweep.(This will work for any figure if its cross-sectional area can be determined from h). |
If we can calculate the volume, I think we can check if a point is in a shape using this formula, but I don't know how.
Any ideas?
Re: IsPointInArea -
Sniper Kitty - 23.08.2012
There's alot of these out there...
I made this one myself,
pawn Код:
stock IsPointInArea(Float: X, Float: Y, Float: Z, Float: MinX, Float: MinY, Float: MinZ, Float: MaxX, Float: MaxY, Float: MaxZ) {
if((MinX >= X && X >= MaxX) && (MinY >= Y && Y >= MaxY) && (MinZ >= Z && Z >= MaxZ)) {
return true;
}
return false;
}
*Note*: This will only work with 3D Squares and Rectangles.
Re: IsPointInArea -
Vince - 23.08.2012
I believe someone (I think Ryder) made a function IsPointInPolygon(). Could check that out. I believe it's in the useful functions thread.
Re: IsPointInArea -
Sniper Kitty - 23.08.2012
I found what Vince is talking about,
http://forum.sa-mp.com/showthread.ph...on#post1154971