Random polygon in San Andreas
#1

Hi,
I found function, named IsPointInPolygon(https://sampforum.blast.hk/showthread.php?tid=38965&page=186). I need function, that random generate 4 polygons in San Andreas and write them coords to variable. For example:

First generating:



Second generating:



It will be better if polygon's edge doesn't cross existing polygon edge.

Thanks!
Reply
#2

wait 12 hours not 30 minutes before bumping your topics, and this isn't possible without very intense maths.
Reply
#3

No, I need function that random generate polygon in San Andreas. Then I make checking with IsPointInPolygon.
Reply
#4

pawn Код:
stock ReturnRandomPolygon3(&Float:Point1[2],&Float:Point2[2],&Float:Point[2])
{
    Point1[0] = (random(6000)-3000.0);
    Point1[1] = (random(6000)-3000.0);
    Point2[0] = (random(6000)-3000.0);
    Point2[1] = (random(6000)-3000.0);
    Point3[0] = (random(6000)-3000.0);
    Point3[1] = (random(6000)-3000.0);
}

stock ReturnRandomPolygon3ex(&Float:Point1[2],&Float:Point2[2],&Float:Point3[2])//other function
{
    Point1[0] = (random(6000)-3000.0);
    Point1[1] = (random(6000)-3000.0);
    while(IsPointInPoligon(Point1[0],Point1[1],...yourPolygon...)
    {
        Point1[0] = (random(6000)-3000.0);
        Point1[1] = (random(6000)-3000.0);
    }
    Point2[0] = (random(6000)-3000.0);
    Point2[1] = (random(6000)-3000.0);
    while(IsPointInPoligon(Point2[0],Point2[1],...yourPolygon...)
    {
        Point2[0] = (random(6000)-3000.0);
        Point2[1] = (random(6000)-3000.0);
    }
    Point3[0] = (random(6000)-3000.0);
    Point3[1] = (random(6000)-3000.0);
    while(IsPointInPoligon(Point3[0],Point3[1],...yourPolygon...)
    {
        Point3[0] = (random(6000)-3000.0);
        Point3[1] = (random(6000)-3000.0);
    }
}

example use:
new Float:Points[3][2];
ReturnRandomPolygon3(Points[0],Points[1],Points[2]);

Edit the functions so they meet your requirements..
Reply
#5

Thank you very much! Hm, what do you mean ...yourPolygon...?
Reply
#6

Quote:
Originally Posted by zgintasz
Посмотреть сообщение
Thank you very much! Hm, what do you mean ...yourPolygon...?
Just use the function ispointinpolygon correctly ;>
Reply
#7

Okay, thank you very much : ).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)