Dynamic areas cross each other -
pasha97 - 18.03.2013
My problem is hard to be explained without pictures, so I created this:
Re: Dynamic areas cross each other -
Misiur - 18.03.2013
Interesting problem. However solution is simple - intersecting circles equation. For example:
http://answers.yahoo.com/question/in...1012843AAcLBwP
Re: Dynamic areas cross each other -
pasha97 - 18.03.2013
Quote:
Originally Posted by Misiur
|
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.
Re: Dynamic areas cross each other -
Misiur - 18.03.2013
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.
Re: Dynamic areas cross each other -
ReneG - 18.03.2013
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.
Re: Dynamic areas cross each other -
pasha97 - 18.03.2013
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.
Re: Dynamic areas cross each other -
pasha97 - 18.03.2013
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;
}
Re: Dynamic areas cross each other -
ReneG - 18.03.2013
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.