#include <iostream>
#include <vector>
#include <limits>
using namespace std;
// Define um tipo genérico para um ponto 2D
class Ponto2D
{
public:
float x;
float y;
Ponto2D(float x = 0, float y = 0)
{
this->x = x;
this->y = y;
}
};
int main() {
// Cria o vetor com todos os pontos do seu objeto
vector<Ponto2D> pontos;
// Adiciona os pontos do corpo
pontos.push_back(Ponto2D(0.0, 0.0));
pontos.push_back(Ponto2D(0.8, 0.0));
pontos.push_back(Ponto2D(0.8, 0.25));
pontos.push_back(Ponto2D(0.0, 0.25));
// Adiciona os pontos da asa direita
pontos.push_back(Ponto2D(0.0, 0.0));
pontos.push_back(Ponto2D(2.0, 1.0));
pontos.push_back(Ponto2D(0.0, 2.0));
// Adiciona os pontos da asa esquerda
pontos.push_back(Ponto2D(0.0, 1.0));
pontos.push_back(Ponto2D(2.0, 0.0));
pontos.push_back(Ponto2D(2.0, 2.0));
// Calcula o bounding box para a colisão
float xmin, xmax, ymin, ymax;
xmin = ymin = numeric_limits<float>::max();
xmax = ymax = numeric_limits<float>::min();
for(auto &ponto : pontos)
{
if(ponto.x < xmin)
xmin = ponto.x;
if(ponto.x > xmax)
xmax = ponto.x;
if(ponto.y < ymin)
ymin = ponto.y;
if(ponto.y > ymax)
ymax = ponto.y;
}
cout << "xmin: " << xmin << " xmax: " << xmax << endl;
cout << "ymin: " << ymin << " ymax: " << ymax << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bGltaXRzPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCi8vIERlZmluZSB1bSB0aXBvIGdlbsOpcmljbyBwYXJhIHVtIHBvbnRvIDJECmNsYXNzIFBvbnRvMkQKewpwdWJsaWM6CiAgICBmbG9hdCB4OwogICAgZmxvYXQgeTsKICAgIAoJUG9udG8yRChmbG9hdCB4ID0gMCwgZmxvYXQgeSA9IDApCgl7CgkJdGhpcy0+eCA9IHg7CgkJdGhpcy0+eSA9IHk7Cgl9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IHsKICAgIAlpZihwb250by54IDwgeG1pbikKICAgIAkJeG1pbiA9IHBvbnRvLng7CiAgICAJaWYocG9udG8ueCA+IHhtYXgpCiAgICAJCXhtYXggPSBwb250by54OwogICAgCWlmKHBvbnRvLnkgPCB5bWluKQogICAgCQl5bWluID0gcG9udG8ueTsKICAgIAlpZihwb250by55ID4geW1heCkKICAgIAkJeW1heCA9IHBvbnRvLnk7CiAgICB9CiAgICAKCWNvdXQgPDwgInhtaW46ICIgPDwgeG1pbiA8PCAiIHhtYXg6ICIgPDwgeG1heCA8PCBlbmRsOwoJY291dCA8PCAieW1pbjogIiA8PCB5bWluIDw8ICIgeW1heDogIiA8PCB5bWF4IDw8IGVuZGw7CgkKCXJldHVybiAwOwp9