1
0
This commit is contained in:
2019-05-15 16:46:55 +02:00
parent 6e1f8bbf63
commit de4d08b938
3 changed files with 18 additions and 10 deletions

View File

@@ -23,7 +23,7 @@ namespace TMI_practicum
public IList<Intersection> FindIntersections(Circle c1)
{
var intersections = new List<Intersection>();
IList<Intersection> intersections;
double d = Distance(c1);
if (d > R + c1.R || d < Math.Abs(R - c1.R) || d == 0.0 && R - c1.R == 0.0) return null;
@@ -35,13 +35,15 @@ namespace TMI_practicum
double htemp = Math.Round(R * R - a * a, 15);
if (htemp == 0)
{
intersections.Add(new Intersection(px, py));
intersections = new Intersection[1];
intersections[0] = new Intersection(px, py);
}
else
{
intersections = new Intersection[2];
double h = Math.Round(Math.Sqrt(htemp), 15);
intersections.Add(new Intersection(px + h * (c1.Y - Y) / d, py - h * (c1.X - X) / d));
intersections.Add(new Intersection(px - h * (c1.Y - Y) / d, py + h * (c1.X - X) / d));
intersections[0] = new Intersection(px + h * (c1.Y - Y) / d, py - h * (c1.X - X) / d);
intersections[1] = new Intersection(px - h * (c1.Y - Y) / d, py + h * (c1.X - X) / d);
}
return intersections;