#include "Primitives.hpp" Rectangle::Rectangle(double _x, double _y, double _h_x, double _h_y, bool _excluded, int _btype) : x(_x), y(_y), h_x(_h_x), h_y(_h_y) { excluded = _excluded; bound_type = _btype; } std::pair Rectangle::missX(double _y) { return { 0.5 / h_x + x, -0.5 / h_x + x }; } std::pair Rectangle::missY(double _x) { return { 0.5 / h_y + y, -0.5 / h_y + y }; } std::pair Rectangle::size() { return { 1 / h_x, 1 / h_y }; } double Rectangle::Function(double _x, double _y) { return std::max(h_x * std::abs(_x - x), h_y * std::abs(_y - y)); } bool Rectangle::Inhere(double x, double y) { return Function(x, y) <= EPS_RECTANGLE; } Circle::Circle(double _x, double _y, double _h_x, double _h_y, bool _excluded, int _btype) : x(_x), y(_y), h_x(_h_x), h_y(_h_y) { excluded = _excluded; bound_type = _btype; } std::pair Circle::missY(double _x) { return { std::sqrt(1 - pow((h_x * (_x - x)), 2)) / h_y + y, -std::sqrt(1 - pow((h_x * (_x - x)), 2)) / h_y + y }; } std::pair Circle::missX(double _y) { return { std::sqrt(1 - pow((h_y * (_y - y)), 2)) / h_x + x, -std::sqrt(1 - pow((h_y * (_y - y)), 2)) / h_x + x }; } double Circle::Function(double _x, double _y) { return pow(h_x * (_x - x), 2) + pow(h_y * (_y - y), 2); } std::pair Circle::size() { return { 1 / h_x, 1 / h_y }; } bool Circle::Inhere(double x, double y) { return Function(x, y) <= EPS_CIRCLE; } Arc::Arc(double _x, double _y, double _h_x, double _h_y, bool _excluded, int _btype) : x(_x), y(_y), h_x(_h_x), h_y(_h_y) { excluded = _excluded; bound_type = _btype; } std::pair Arc::missY(double _x) { return { std::sqrt(1 - pow((h_x * (_x - x)), 2)) / h_y + y, std::sqrt(1 - pow((h_x * (_x - x)), 2)) / h_y + y }; } std::pair Arc::missX(double _y) { return { std::sqrt(1 - pow((h_y * (_y - y)), 2)) / h_x + x, std::sqrt(1 - pow((h_y * (_y - y)), 2)) / h_x + x }; } double Arc::Function(double _x, double _y) { if (_x >= x && _y >= y) { return pow(h_x * (_x - x), 2) + pow(h_y * (_y - y), 2); } return -1.0; } std::pair Arc::size() { return { 1 / h_x, 1 / h_y }; } bool Arc::Inhere(double x, double y) { return Function(x, y) >= 1; }