Dynamic areas cross each other
#1

My problem is hard to be explained without pictures, so I created this:
Reply
#2

Interesting problem. However solution is simple - intersecting circles equation. For example: http://answers.yahoo.com/question/in...1012843AAcLBwP
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Interesting problem. However solution is simple - intersecting circles equation. For example: http://answers.yahoo.com/question/in...1012843AAcLBwP
If it was written in russia, i'd understand all it, but as english is not my native language, it's quite hard to understand for me. As i see, circles intersect when the sum of their radius is bigger than the distance between their cdenters. That is useful. What if do the folowing: for every dynamic circle check wether th distance from player to it si bigger than the sum of radiuses or not.
Reply
#4

I only understand cyrillic, but I don't know how to search russian part of internet, sorry.

My suggestion is: fetch only circles within some range, because for very distant circles such calculations will be a waste of CPU usage.
Reply
#5

Assuming all safe zones are the same radius, can't you just use the distance formula to check if the player is closer than 2 * radius.
Reply
#6

Quote:
Originally Posted by Misiur
Посмотреть сообщение
I only understand cyrillic, but I don't know how to search russian part of internet, sorry.

My suggestion is: fetch only circles within some range, because for very distant circles such calculations will be a waste of CPU usage.
The only problem is that there is no such functions as: GetDynamicCirclePos or GetDynamicCircleRadius. But i think it can be scripted.
Reply
#7

Is that OK? I created this:

pawn Код:
WillAreaCollapse(Float:x,Float:y,Float:radius)
{
    new Float:dis,Float:radsum;
    for(new i=0;i<MAX_ZONES;i++)
    {
        dis=GetDistanceBetweenPoints(x,y,0,CirclePosRad[i][0],CirclePosRad[i][1],0);
        if(dis<50)
        {
        radsum=radius+CirclePosRad[i][2];
        if(radsum>dis) return 1;
        }

    }
    return 0;
}
Reply
#8

I thought the radius of each safezone was a constant term?

Basically you don't want 2 congruent circles (safe zones) to overlap. So this is as close as two safe zones can get.


The closest distance these two safe zones can get without overlapping is 2 times radius.

So if a player gets to choose his safe zone, just loop through all safezones to check if he is range of 2 * r from the center of each one.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)