This commit is contained in:
2025-05-15 02:00:37 +03:00
parent 7c53da7199
commit 6482df0727
13 changed files with 205 additions and 206 deletions

View File

@@ -1,95 +1,95 @@
#include "Primitives.hpp"
Rectangle::Rectangle(double a, double b, double h_x, double h_y, bool excluded, int btype) : a_(a), b_(b), h_x_(h_x), h_y_(h_y) {
excluded_ = excluded;
bound_type = btype;
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<double, double> Rectangle::missX(double y) {
return { 0.5 / h_x_ + a_, -0.5 / h_x_ + a_ };
std::pair<double, double> Rectangle::missX(double _y) {
return { 0.5 / h_x + x, -0.5 / h_x + x };
}
std::pair<double, double> Rectangle::missY(double x) {
return { 0.5 / h_y_ + b_, -0.5 / h_y_ + b_ };
std::pair<double, double> Rectangle::missY(double _x) {
return { 0.5 / h_y + y, -0.5 / h_y + y };
}
std::pair<double, double> Rectangle::size() {
return { 1 / h_x_, 1 / h_y_ };
return { 1 / h_x, 1 / h_y };
}
double Rectangle::Function(double x, double y) {
return std::max(h_x_ * std::abs(x - a_), h_y_ * std::abs(y - b_));
double Rectangle::Function(double _x, double _y) {
return std::max(h_x * std::abs(_x - x), h_y * std::abs(_y - y));
}
std::pair<double, double> Rectangle::Second_Deriative(double x, double y) {
return { (h_x_ / 2) * ((x - a_) / std::abs(x - a_)), (h_y_ / 2) * ((y - b_) / std::abs(y - b_)) };
std::pair<double, double> Rectangle::Second_Deriative(double _x, double _y) {
return { (h_x / 2) * ((_x - x) / std::abs(_x - x)), (h_y / 2) * ((_y - y) / std::abs(_y - y)) };
}
bool Rectangle::Inhere(double x, double y) {
return Function(x, y) <= EPS_RECTANGLE;
}
Circle::Circle(double a, double b, double h_x, double h_y, bool excluded, int btype) : a_(a), b_(b), h_x_(h_x), h_y_(h_y) {
excluded_ = excluded;
bound_type = btype;
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<double, double> Circle::missY(double x) {
return { std::sqrt(1 - pow((h_x_ * (x - a_)), 2)) / h_y_ + b_, -std::sqrt(1 - pow((h_x_ * (x - a_)), 2)) / h_y_ + b_ };
std::pair<double, double> 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<double, double> Circle::missX(double y) {
return { std::sqrt(1 - pow((h_y_ * (y - b_)), 2)) / h_x_ + a_, -std::sqrt(1 - pow((h_y_ * (y - b_)), 2)) / h_x_ + a_ };
std::pair<double, double> 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 - a_), 2) + pow(h_y_ * (y - b_), 2);
double Circle::Function(double _x, double _y) {
return pow(h_x * (_x - x), 2) + pow(h_y * (_y - y), 2);
}
std::pair<double, double> Circle::Second_Deriative(double x, double y) {
return { 2 * h_x_ * (x - a_), 2 * h_y_ * (y - b_) };
std::pair<double, double> Circle::Second_Deriative(double _x, double _y) {
return { 2 * h_x * (_x - x), 2 * h_y * (_y - y) };
}
std::pair<double, double> Circle::size() {
return { 1 / h_x_, 1 / h_y_ };
return { 1 / h_x, 1 / h_y };
}
bool Circle::Inhere(double x, double y) {
return Function(x, y) <= EPS_CIRCLE;
}
Arc::Arc(double a, double b, double h_x, double h_y, bool excluded, int btype) : a_(a), b_(b), h_x_(h_x), h_y_(h_y) {
excluded_ = excluded;
bound_type = btype;
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<double, double> Arc::missY(double x) {
return { std::sqrt(1 - pow((h_x_ * (x - a_)), 2)) / h_y_ + b_, std::sqrt(1 - pow((h_x_ * (x - a_)), 2)) / h_y_ + b_ };
std::pair<double, double> 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<double, double> Arc::missX(double y) {
return { std::sqrt(1 - pow((h_y_ * (y - b_)), 2)) / h_x_ + a_, std::sqrt(1 - pow((h_y_ * (y - b_)), 2)) / h_x_ + a_ };
std::pair<double, double> 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 >= a_ && y >= b_) {
return pow(h_x_ * (x - a_), 2) + pow(h_y_ * (y - b_), 2);
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<double, double> Arc::Second_Deriative(double x, double y) {
if (x >= a_ && y >= b_) {
return { 2 * h_x_ * (x - a_), 2 * h_y_ * (y - b_) };
std::pair<double, double> Arc::Second_Deriative(double _x, double _y) {
if (_x >= x && _y >= y) {
return { 2 * h_x * (_x - x), 2 * h_y * (_y - y) };
}
if (x < a_) {
//std::cout << "x < a\n";
if (_x < x) {
//std::cout << "_x < a\n";
}
if (y < b_) {
//std::cout << "y < b\n";
if (_y < y) {
//std::cout << "_y < b\n";
}
return { -1.0, -1.0 };
}
std::pair<double, double> Arc::size() {
return { 1 / h_x_, 1 / h_y_ };
return { 1 / h_x, 1 / h_y };
}
bool Arc::Inhere(double x, double y) {