IsPointInArea
#1

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?
Reply
#2

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.
Reply
#3

I believe someone (I think Ryder) made a function IsPointInPolygon(). Could check that out. I believe it's in the useful functions thread.
Reply
#4

I found what Vince is talking about,
http://forum.sa-mp.com/showthread.ph...on#post1154971
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)