Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- auto findY1ellipse(float x) // Создадим функцию для поиска у эллипса
- {
- const float x0 = 11.9012f; // Введем переменные
- const int y0 = 3;
- const int a = 30;
- const int b = 37;
- const int a2 = 900;
- double y = b * sqrt(1 - (x - x0) * (x - x0) / a2) + y0; // выразим у
- y = (int)(y * 10000) / 10000.; // Округлим для нашей точности в 0.0001
- return y;
- }
- auto findY2ellipse(float x) // Создадим функцию для поиска у эллипса
- {
- const float x0 = 11.9012f; // Введем переменные
- const int y0 = 3;
- const int a = 30;
- const int b = 37;
- const int a2 = 900;
- double y = b * sqrt(1 - (x - x0) * (x - x0) / a2); // выразим у
- y = (int)(y * 10000) / 10000.; // Округлим для нашей точности в 0.0001
- float y2 = -1*y + y0;
- return y2;
- }
- auto findY1circle(float x)
- {
- const int x0 = -11;
- const float y0 = -12.3423f;
- const int r2 = 729;
- double y = sqrt(r2 - (x - x0)*(x - x0));
- y = (int)(y * 10000) / 10000.; // Округлим для нашей точности в 0.0001
- return y + y0;
- }
- auto findY2circle(float x)
- {
- const int x0 = -11;
- const float y0 = -12.3423f;
- const int r2 = 729;
- double y = -1 * sqrt(r2 - (x - x0) * (x - x0));
- y = (int)(y * 10000) / 10000.; // Округлим для нашей точности в 0.0001
- return y + y0;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- for (float x = -18; x <= 20; x += 0.0001)
- {
- float Y1e = findY1ellipse(x);
- float Y2e = findY2ellipse(x);
- float Y1c = findY1circle(x);
- float Y2c = findY2circle(x);
- if ((Y1c / Y1e < 1.00001) and (Y1c / Y1e > 0.999999)) {
- cout << "Первая точка:" << endl;
- cout << "координата X = " << x << endl;
- cout << "координата Y = " << Y1e << endl;
- cout << "" << endl;
- }
- if ((Y2c / Y2e < 1.00000001) and (Y2c / Y2e > 0.99999999)) {
- cout << "Вторая точка:" << endl;
- cout << "координата X = " << x << endl;
- cout << "координата Y = " << Y2e << endl;
- cout << "" << endl;
- cout << "Работу выполнил Бочкарев А.Н. КЗИ-21-1б" << endl;
- }
- }
- }
Add Comment
Please, Sign In to add comment