Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat.
TIBIANTIS.ONLINE NAJLEPSZY SERWER 7.4
ONLINE SINCE 2020
TIBIANTIS.ONLINE NAJLEPSZY SERWER 7.4
ONLINE SINCE 2020
TIBIANTIS.ONLINE NAJLEPSZY SERWER 7.4
ONLINE SINCE 2020
void circle() {
uniform_real_distribution<double> distrx(min_x + 2, max_x - 2);
uniform_real_distribution<double> distry(min_y + 2, max_y - 2);
for (int i = 0; i < 100000; ++i) {
do {
double najblizszy = DBL_MAX;
Point temp = { distrx(gen),distry(gen) };
for (int j = 0; j < i; j++)
if (circles[j].x <= temp.x + 2 && circles[j].x >= temp.x - 2)
najblizszy = min(najblizszy, dist(circles[j], temp));
if(najblizszy > 2) circles[i] = { temp };
} while (najblizszy <= 2);
}
}
void genCircle::circle() {
uniform_real_distribution<double> distrx(min_x + circleRadius, max_x - circleRadius);
uniform_real_distribution<double> distry(min_y + circleRadius, max_y - circleRadius);
for (int i = 0; i < circleAmount; ++i) {
do {
najblizszy = DBL_MAX;
Point temp = { distrx(gen),distry(gen) };
map<double, double>::iterator it, low, lowest, high, highest;
lowest = circles.lower_bound(temp.x);
highest = circles.upper_bound(temp.x);
if (circles.size() >= 1) {
if (lowest != circles.begin()) lowest = prev(lowest);
if (highest == circles.end()) highest = prev(highest);
do {
low = lowest, high = highest;
if ((*lowest).first >= temp.x - 2 * circleRadius) // jesli istnieje jakis punkt w zakresie od x-2*circleradius do x+2*circleradius
if (lowest != circles.begin()) lowest = prev(lowest); // przesunac lowest zeby sprawdzic czy poprzedni element tez spelnia powyzszy warunek
if ((*highest).first <= temp.x + 2 * circleRadius)
if (next(highest) != circles.end()) highest = next(highest); // przesunac highest zeby sprawdzic czy nastepny element tez spelnia powyzszy warunek
} while (low != lowest || high != highest);
for (it = lowest; it != highest; ++it) najblizszy = min(najblizszy, dist({ (*it).first,(*it).second }, temp)); // sprawdzic odleglosc wszystkie elementow w przedziale od lowest do highest
}
if (najblizszy > 2 * circleRadius) circles.insert(make_pair(temp.x, temp.y)); // dopoki istnieje jakis ktorego odleglosc jest mniejsza niz 2*circleradius to losuj temp jeszcze raz, w innym przypadku wrzuc temp w mape
} while (najblizszy <= 2 * circleRadius);
}
}
void genCircle::circle() {
uniform_real_distribution<double> distrx(min_x + circleRadius, max_x - circleRadius);
uniform_real_distribution<double> distry(min_y + circleRadius, max_y - circleRadius);
for (int i = 0; i < circleAmount; ++i) {
do {
Point temp = { distrx(gen),distry(gen) };
map<double, double>::iterator it, low, lowest, high, highest;
lowest = circles.lower_bound(temp.x);
highest = circles.upper_bound(temp.x);
if (circles.size() >= 1) {
if (lowest != circles.begin()) lowest = prev(lowest);
if (highest == circles.end()) highest = prev(highest);
do {
low = lowest;
high = highest;
if ((*lowest).first >= temp.x - 2 * circleRadius) { // if point exist in range x-2*circleradius, x+2*circleradius
closest = DBL_MAX;
closest = min(closest, dist({ (*lowest).first,(*lowest).second }, temp));
if (lowest != circles.begin())
lowest = prev(lowest); // move lowest to check for previous element
}
if ((*highest).first <= temp.x + 2 * circleRadius) {
closest = DBL_MAX;
closest = min(closest, dist({ (*highest).first,(*highest).second }, temp));
if (next(highest) != circles.end())
highest = next(highest);
}
} while (low != lowest || high != highest);
}
if (closest > 2 * circleRadius) circles.insert(make_pair(temp.x, temp.y)); // insert if temp doesnt overlap anything, else reroll
} while (closest <= 2 * circleRadius);
}
}
Ostatnio zmieniony przez moth : 25-04-2021, 14:20
Problem z komputerem? Instrukcja diagnostyczna
Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat."Don't worry, I'm just a pervert"Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat.
Problem z komputerem? Instrukcja diagnostyczna
Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat."Don't worry, I'm just a pervert"Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat.
Aktualnie 1 użytkowników przegląda ten temat. (0 użytkowników i 1 gości)
Zakładki