public static Point2D[] GetIntersections(Circle2D circle, Line2D line, double precision) { Vector2D direction = line.Direction; double lengthSquared = direction.GetLengthSquared(); Vector2D center = (Vector2D)circle.center; Point2D point2D1 = line.Origin - center; Point2D point2D2 = point2D1 + direction; double num1 = point2D1.X * point2D2.Y - point2D2.X * point2D1.Y; double num2 = circle.radius * circle.radius * lengthSquared - num1 * num1; Point2D[] point2DArray = (Point2D[])null; if (MathUtil.AreApproxEqual(0.0, num2, precision * precision)) { double num3 = num1 * direction.Y; double num4 = -num1 * direction.X; point2DArray = new Point2D[1] { new Point2D(num3 / lengthSquared, num4 / lengthSquared) + center }; } else if (num2 > 0.0) { double num3 = direction.Y < 0.0 ? -1.0 : 1.0; double num4 = num1 * direction.Y; double num5 = -num1 * direction.X; double num6 = System.Math.Sqrt(num2); double num7 = num3 * direction.X * num6; double num8 = System.Math.Abs(direction.Y) * num6; point2DArray = new Point2D[2] { new Point2D((num4 + num7) / lengthSquared, (num5 + num8) / lengthSquared) + center, new Point2D((num4 - num7) / lengthSquared, (num5 - num8) / lengthSquared) + center }; } return(point2DArray); }
public static void GetIntersections( Circle2D circle, Arc2D arc, double precision, out Point2D[] intersections, out bool overlap) { intersections = (Point2D[])null; overlap = false; Vector2D vector2D1 = arc.center - circle.Center; double length = vector2D1.GetLength(); if (System.Math.Abs(length) <= precision) { if (!MathUtil.AreApproxEqual(circle.Radius, arc.radius, precision)) { return; } overlap = true; } else { Vector2D vector2D2 = vector2D1 / length; double num1 = length; double num2 = num1 * num1; double num3 = circle.Radius * circle.Radius; double num4 = arc.radius * arc.radius; double num5 = num2 - num4 + num3; double d = (4.0 * num2 * num3 - num5 * num5) / (4.0 * num2); if (d < -precision) { return; } double num6 = num5 / (2.0 * num1); if (d <= precision) { Point2D point = circle.Center + num6 * vector2D2; if (!arc.ContainsAngleProjection(point)) { return; } intersections = new Point2D[1] { point }; } else { double a = System.Math.Sqrt(d); if (MathUtil.AreApproxEqual(a, 0.0, precision)) { Point2D point = circle.Center + num6 * vector2D2; if (!arc.ContainsAngleProjection(point)) { return; } intersections = new Point2D[1] { point }; } else { Vector2D vector2D3 = new Vector2D(vector2D2.Y, -vector2D2.X); List <Point2D> point2DList = new List <Point2D>(2); Point2D point1 = circle.Center + num6 * vector2D2 + a * vector2D3; if (arc.ContainsAngleProjection(point1)) { point2DList.Add(point1); } Point2D point2 = circle.Center + num6 * vector2D2 - a * vector2D3; if (arc.ContainsAngleProjection(point2)) { point2DList.Add(point2); } if (point2DList.Count <= 0) { return; } intersections = point2DList.ToArray(); } } } }
public static Point2D[] GetIntersections(Circle2D circle, Line2D line) { return(Circle2D.GetIntersections(circle, line, 8.88178419700125E-16)); }
public Point2D[] GetIntersections(Line2D line, double precision) { return(Circle2D.GetIntersections(this, line, precision)); }
public Class201(Circle2D circle) { this.point2D_0 = circle.Center; this.double_1 = circle.Radius; }
public static void GetIntersections( Circle2D circle1, Circle2D circle2, double precision, out Point2D[] intersections, out bool overlap) { intersections = (Point2D[])null; overlap = false; Vector2D vector2D1 = circle2.center - circle1.center; double length = vector2D1.GetLength(); if (System.Math.Abs(length) <= precision) { if (!MathUtil.AreApproxEqual(circle1.radius, circle2.radius, precision)) { return; } overlap = true; } else { Vector2D vector2D2 = vector2D1 / length; double num1 = length; double num2 = num1 * num1; double num3 = circle1.radius * circle1.radius; double num4 = circle2.radius * circle2.radius; double num5 = num2 - num4 + num3; double d = (4.0 * num2 * num3 - num5 * num5) / (4.0 * num2); if (d < -precision) { return; } double num6 = num5 / (2.0 * num1); if (d < 0.0) { Point2D point2D = circle1.center + num6 * vector2D2; intersections = new Point2D[1] { point2D }; } else { double a = System.Math.Sqrt(d); if (MathUtil.AreApproxEqual(a, 0.0, precision)) { Point2D point2D = circle1.center + num6 * vector2D2; intersections = new Point2D[1] { point2D }; } else { Vector2D vector2D3 = new Vector2D(vector2D2.Y, -vector2D2.X); Point2D point2D1 = circle1.center + num6 * vector2D2 + a * vector2D3; Point2D point2D2 = circle1.center + num6 * vector2D2 - a * vector2D3; intersections = new Point2D[2] { point2D1, point2D2 }; } } } }