Answer the question
In order to leave comments, you need to log in
How to check whether a triangle belongs to the intersection of two circles?
There is a task:
Треугольник и круг. Лежит ли заданой площади треугольник
AВС в области пересечения заданых кругов:
(х-а1)^2 + (y-b1)^2 <= r1^2
(х-а2)^2 + (у-b2)^2 <= r2^ 2
#include <iostream>
#include <math.h>
// #include <Windows.h>
using namespace std;
int main(){
// SetConsoleOutputCP(1251);
float x,y,a1,b1,a2,b2,result,r1,r2;
cout << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
cout << "a1: ";
cin >> a1;
cout << "b1: ";
cin >> b1;
cout << "a2: ";
cin >> a2;
cout << "b2: ";
cin >> b2;
cout<< "r1: ";
cin >> r1;
cout << "r2: ";
cin >> r2;
pow(r1,2) >= pow((x - a1),2) + pow((y - b1),2);
pow(r2,2) >= pow((x - a2),2) + pow((y - b2),2);
if(pow(r1,2) >= pow((x - a1),2) + pow((y - b1),2)){
cout << "text:true";
}
cout << "r1: " << r1;
cout << " r2: " << r2<<endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
The triangle lies at the intersection of circles" means that all points of the triangle belong to the intersection of circles, that is, they simultaneously belong to both circles.
Since the intersection of circles is a convex figure, and the sides of the triangle are line segments, it is enough to make sure that all three vertices simultaneously belong to both circles.
A triangle has three corners, right?
And you need each of the corners to lie inside both circles.
So check each of the vertices for being in both circles.
And now you only check one point.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question