# include
# include
Struct point_t {
Double x, y;
};
Struct circle_t {
Struct point_t center;
Double r;
};
Int double_equals (double const a, double const b)
{
The static const double ZERO e=1-15;
Return fabs (a - b) & lt; ZERO;
}
A, double distance_sqr (struct point_t const * struct point_t const * b)
{
Return (a - & gt; X - b - & gt; X) * (a - & gt; X - b - & gt; X) + (a - & gt; Y - b - & gt; Y) * (a - & gt; Y - b - & gt; Y);
}
A, double short (struct point_t const * struct point_t const * b)
{
Return SQRT (distance_sqr (a, b));
}
Int insect (struct circle_t circles [], struct point_t points [])
{
Double d, a, b, c, p, q, r.
Double cos_value [2], sin_value [2];
If (double_equals (circles [0]. Center. X, circles. [1] center. X)
& & Double_equals (circles [0]. Center. Y, circles. [1] center. Y)
& & Double_equals (circles [0]. J r, circles. [1] r)) {
return -1;
}
D=short (& amp; Circles [0]. Center, & amp; Circles [1]. The center);
If (d & gt; Circles [0]. R + circles. [1] r
| | d & lt; Fabs (circles [0]. R - circles. [1] r)) {
return 0;
}
A=2.0 * circles [0]. R * (circles. [0] center. The X-ray circles. [1] center. X);
B=2.0 * circles [0]. R * (circles. [0] center. The y - circles. [1] center. Y);
C=circles. [1] r * circles. [1] r - circles. [0] r * circles. [0] r
- distance_sqr (& amp; Circles [0]. Center, & amp; Circles [1]. The center);
P=a * a + b * b;
Q=2.0 * a * c;
If (double_equals (d, circles [0]. R + circles. [1] r)
| | double_equals (d, fabs (circles. [0] r - circles. [1] r))) {
Cos_value [0]=- q/p/2.0;
Sin_value [0]=SQRT (1 - cos_value cos_value [0] * [0]).
Points [0]. X=circles. [0] r * cos_value [0] + circles. [0] center. X.
Points [0]. Y=circles. [0] r * sin_value [0] + circles. [0] center. Y;
if (! Double_equals (distance_sqr (& amp; Points [0], & amp; Circles [1]. The center),
Circles. [1] r * circles. [1] r)) {
Points [0]. Y=circles. [0] center. The y - circles. [0] r * sin_value [0].
}
return 1;
}
R=c - c * b * b;
Cos_value [0]=(SQRT (q * q - 4.0 * p * r) - q)/p/2.0;
Cos_value [1]=(- SQRT (q * q - 4.0 * p * r) - q)/p/2.0;
Sin_value [0]=SQRT (1 - cos_value cos_value [0] * [0]).
Sin_value [1]=SQRT (1 - cos_value cos_value [1] * [1]).
Points [0]. X=circles. [0] r * cos_value [0] + circles. [0] center. X.
Points [1]. X=circles. [0] r * cos_value [1] + circles. [0] center. X.
Points [0]. Y=circles. [0] r * sin_value [0] + circles. [0] center. Y;
Points. [1] y=circles. [0] r * sin_value [1] + circles. [0] center. Y;
if (! Double_equals (distance_sqr (& amp; Points [0], & amp; Circles [1]. The center),
Circles. [1] r * circles. [1] r)) {
Points [0]. Y=circles. [0] center. The y - circles. [0] r * sin_value [0].
}
if (! Double_equals (distance_sqr (& amp; Points [1], & amp; Circles [1]. The center),
Circles. [1] r * circles. [1] r)) {
Points. [1] y=circles. [0] center. The y - circles. [0] r * sin_value [1].
}
If (double_equals (points [0]. J y, points [1]. The y)
& & Double_equals (points [0]. J x, points [1]. X)) {
If (points [0]. Y & gt; 0 {
Points. [1] y=- points [1]. The y;
} else {
Points [0]. Y=- points [0]. Y;
}
}
return 2;
}
Int main ()
{
Struct circle_t circles [2].
Struct point_t points [2].
Printf (" please enter the two round x, y, radius (separated by commas) : ");
Circles [0]. Center. X=0;
Circles [0]. Center. Y=0;
Circles [0]. R=5;
Circles [1]. Center. X=6; Circles [1]. Center. Y=0; Circles [1]. The r=1;
The switch (insect (circles, points))
{
Case 1:
Printf (" THE CIRCLES ARE THE SAME/n ");
break;
Case 0:
Printf (" NO INTERSECTION computes/n ");
break;
Case 1:
Printf (" % f, % f) \ n ", points [0]. J x, points [0]. Y);
break;
Case 2:
Printf (" % f % f) (f % % f) \ n ",
Points [0]. J x, points [0]. J y,
Points [1]. J x, points [1]. The y);
}
return 0;
}
CodePudding user response:
Pointer to visit- patches,,,,,,,
CodePudding user response:
Results no root?CodePudding user response:
Well, it seems that is three circular intersection formula,This is wireless positioning?
CodePudding user response:
Is a mathematical formula,CodePudding user response:
Just a pointer
CodePudding user response:
A - & gt; BEquivalent to
(* a). B
CodePudding user response:
Type a, b, the square of the distance