15 std::vector<BoundingBoxVertex> intersection = rect1;
17 for (std::size_t i = 0; i < rect2.size(); ++i) {
18 if (intersection.size() <= 2) {
22 Line line(rect2[i], rect2[(i + 1) % rect2.size()]);
23 std::vector<BoundingBoxVertex> new_intersection;
24 std::vector<float> line_values;
26 for (
const auto& t : intersection) {
27 line_values.push_back(line(t));
30 for (std::size_t j = 0; j < intersection.size(); ++j) {
33 float s_value = line_values[j];
34 float t_value = line_values[(j + 1) % line_values.size()];
37 new_intersection.push_back(s);
40 if (s_value * t_value < 0) {
42 new_intersection.push_back(intersection_point);
46 intersection = new_intersection;
49 if (intersection.size() <= 2) {
54 for (std::size_t i = 0; i < intersection.size(); ++i) {
60 return 0.5F * std::abs(area);
73 float dy =
width / 2.0F;
74 float dxcos = dx * std::cos(angle);
75 float dxsin = dx * std::sin(angle);
76 float dycos = dy * std::cos(angle);
77 float dysin = dy * std::sin(angle);
79 std::vector<BoundingBoxVertex> vertices;
80 vertices.emplace_back(
center[0] + (-dxcos - -dysin),
center[1] + (-dxsin + -dycos));
81 vertices.emplace_back(
center[0] + (dxcos - -dysin),
center[1] + (dxsin + -dycos));
82 vertices.emplace_back(
center[0] + (dxcos - dysin),
center[1] + (dxsin + dycos));
83 vertices.emplace_back(
center[0] + (-dxcos - dysin),
center[1] + (-dxsin + dycos));