Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Options::Compare(Shape* s1, Shape* s2)
- {
- double ar1, ar2;
- ar1 = s1->getArea();
- ar2 = s2->getArea();
- if (ar1 > ar2)
- {
- cout << "Площадь треугольника больше площади квадрата" << endl;
- }
- else if (ar1 == ar2)
- {
- cout << "Площади фигур равны" << endl;
- }
- else cout << "Площадь квадрата больше площади треугольника" << endl;
- }
- void Options::IsIntersect(Shape* s1, Shape* s2)
- {
- Point *masT, *masS;
- masT = new Point[1];
- masS = new Point[1];
- masT[0] = s1->getCenter();
- masS[0] = s2->getCenter();
- double fs, ss, ts;
- fs = sqrt(pow((s1->arc[0].x - s1->arc[1].x), 2) + pow((s1->arc[0].y - s1->arc[1].y), 2));
- ss = sqrt(pow((s1->arc[0].x - s1->arc[2].x), 2) + pow((s1->arc[0].y - s1->arc[2].y), 2));
- ts = sqrt(pow((s1->arc[1].x - s1->arc[2].x), 2) + pow((s1->arc[1].y + s1->arc[2].y), 2));
- double pr = (fs + ss + ts) / 2;
- double RTri;
- RTri = (fs * ss * ts) / (4 * sqrt(pr*(pr - fs) * (pr - ss) * (pr - ts))); // радиус треугольника
- double RSq;
- RSq = sqrt(pow((s2->arc[0].x - s2->arc[1].x), 2) + pow((s2->arc[0].y - s2->arc[1].y), 2)) * sqrt(2) / 2; // радиус квадрата
- double side;
- side = sqrt(pow((masT->x - masS->x),2) + pow((masT->y - masS->y),2));
- if (side <= RTri + RSq)
- {
- cout << "Вхождение есть" << endl;
- return;
- }
- else cout << "Вхождения нет" << endl;
- }
- void Options::IsInclude(Shape* s1, Shape* s2)
- {
- Point *masT, *masS;
- masT = new Point[1];
- masS = new Point[1];
- masT[0] = s1->getCenter();
- masS[0] = s2->getCenter();
- double fs, ss, ts;
- fs = sqrt(pow((s1->arc[0].x - s1->arc[1].x), 2) + pow((s1->arc[0].y - s1->arc[1].y), 2));
- ss = sqrt(pow((s1->arc[0].x - s1->arc[2].x), 2) + pow((s1->arc[0].y - s1->arc[2].y), 2));
- ts = sqrt(pow((s1->arc[1].x - s1->arc[2].x), 2) + pow((s1->arc[1].y + s1->arc[2].y), 2));
- double pr = (fs + ss + ts) / 2;
- double RTri;
- RTri = (fs * ss * ts) / (4 * sqrt(pr*(pr - fs) * (pr - ss) * (pr - ts))); // радиус треугольника
- double RSq;
- RSq = sqrt(pow((s2->arc[0].x - s2->arc[1].x), 2) + pow((s2->arc[0].y - s2->arc[1].y), 2)) * sqrt(2) / 2; // радиус квадрата
- double side;
- side = sqrt(pow((masT->x - masS->x), 2) + pow((masT->y - masS->y), 2)); // длина от центра масс
- if (RTri >= RSq)
- {
- if (side + RSq <= RTri)
- {
- cout << "Полное вхождение" << endl;
- }
- else cout << "Нет полного вхождения " << endl;
- }
- else
- {
- if (side + RTri <= RSq)
- {
- cout << "Полное вхождения" << endl;
- }
- else cout << "Нет полного вхождения" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement