public static Inclusions PointInCircle0( double centerX, double centerY, double radius, double x, double y) { var distance = Distance2DTests.Distance2D(centerX, centerY, x, y); return((radius >= distance) ? ((Abs(radius - distance) < DoubleEpsilon) ? Inclusions.Boundary : Inclusions.Inside) : Inclusions.Outside); }
public static Circle2D?TripointCircle( double PointAX, double PointAY, double PointBX, double PointBY, double PointCX, double PointCY) { (var X, var Y) = CircleCenterThreePointsTests.CenterCircleThreePoints(PointAX, PointAY, PointBX, PointBY, PointCX, PointCY) ?? (0d, 0d); var radius = Distance2DTests.Distance2D(X, Y, PointAX, PointAY); return(new Circle2D(X, Y, radius)); }
public static Rectangle2D TripointCircleBounds( double PointAX, double PointAY, double PointBX, double PointBY, double PointCX, double PointCY) { (var X, var Y) = CircleCenterThreePointsTests.CenterCircleThreePoints(PointAX, PointAY, PointBX, PointBY, PointCX, PointCY) ?? (0d, 0d); var Radius = Distance2DTests.Distance2D(X, Y, PointAX, PointAY); return(Rectangle2D.FromLTRB(X - Radius, Y - Radius, X + Radius, Y + Radius)); }
public static (double x, double y) TriangleCenter1(double ax, double ay, double bx, double by, double cx, double cy) { var a = Distance2DTests.Distance2D(bx, by, cx, cy); var b = Distance2DTests.Distance2D(ax, ay, cx, cy); var c = Distance2DTests.Distance2D(bx, by, ax, ay); var p = a + b + c; // This will throw if the center is the origin... return( x : ((a * ax) + (b * bx) + (c * cx)) / p, y : ((a * ay) + (b * by) + (c * cy)) / p ); }
public static bool PointOnLine( double segmentAX, double segmentAY, double segmentBX, double segmentBY, double pointX, double pointY) { var Length1 = Distance2DTests.Distance2D(pointX, pointY, segmentBX, segmentBY); // Sqrt((Point.X - Line.B.X) ^ 2 + (Point.Y - Line.B.Y)) var Length2 = Distance2DTests.Distance2D(pointX, pointY, segmentAX, segmentAY); // Sqrt((Point.X - Line.A.X) ^ 2 + (Point.Y - Line.A.Y)) return(Abs(Distance2DTests.Distance2D(segmentAX, segmentAY, segmentBX, segmentBY) - Length1 + Length2) < DoubleEpsilon); }