示例#1
0
        [TestCase(5, 16, 15, 6, 5, 6, 6)]  // No Intersection in translated coordinates
        public static void IntersectionCoordinates_Static_of_Not_Intersecting_Returns_Empty_Array(
            double x1, double y1, double x2, double y2,
            double x, double y, double r)
        {
            LinearCurve curve1 = new LinearCurve(new CartesianCoordinate(x1, y1), new CartesianCoordinate(x2, y2));

            curve1.Tolerance = Tolerance;
            CircularCurve curve2 = new CircularCurve(r, new CartesianCoordinate(x, y));

            curve2.Tolerance = Tolerance;

            CartesianCoordinate[] intersectionCoordinates = IntersectionLinearCircular.IntersectionCoordinates(curve1, curve2);

            Assert.AreEqual(0, intersectionCoordinates.Length);
        }
示例#2
0
        [TestCase(5, 14.4852813742386, 13.4852813742386, 6, 5, 6, 6, 9.24264068711928, 10.2426406871193)]     // Sloped Tangent in Quadrant 1 in translated coordinates
        public static void IntersectionCoordinates_Static_of_Tangents_Returns_Tangent_Coordinate(
            double x1, double y1, double x2, double y2,
            double x, double y, double r,
            double x1Expected, double y1Expected)
        {
            LinearCurve curve1 = new LinearCurve(new CartesianCoordinate(x1, y1), new CartesianCoordinate(x2, y2));

            curve1.Tolerance = Tolerance;
            CircularCurve curve2 = new CircularCurve(r, new CartesianCoordinate(x, y));

            curve2.Tolerance = Tolerance;

            CartesianCoordinate[] intersectionCoordinates = IntersectionLinearCircular.IntersectionCoordinates(curve1, curve2);

            Assert.AreEqual(1, intersectionCoordinates.Length);
            Assert.AreEqual(x1Expected, intersectionCoordinates[0].X, Tolerance);
            Assert.AreEqual(y1Expected, intersectionCoordinates[0].Y, Tolerance);
        }
示例#3
0
        [TestCase(5, 13, 12, 6, 5, 6, 6, 6.102084, 11.897916, 10.897916, 7.102084)] // Sloped Intersection in translated coordinates
        public static void IntersectionCoordinates(
            double x1, double y1, double x2, double y2,
            double x, double y, double r,
            double x1Expected, double y1Expected,
            double x2Expected, double y2Expected)
        {
            LinearCurve curve1 = new LinearCurve(new CartesianCoordinate(x1, y1), new CartesianCoordinate(x2, y2));

            curve1.Tolerance = Tolerance;
            CircularCurve curve2 = new CircularCurve(r, new CartesianCoordinate(x, y));

            curve2.Tolerance = Tolerance;

            IntersectionLinearCircular intersections = new IntersectionLinearCircular(curve1, curve2);

            CartesianCoordinate[] intersectionCoordinates = intersections.IntersectionCoordinates();

            Assert.AreEqual(x1Expected, intersectionCoordinates[0].X, Tolerance);
            Assert.AreEqual(y1Expected, intersectionCoordinates[0].Y, Tolerance);
            Assert.AreEqual(x2Expected, intersectionCoordinates[1].X, Tolerance);
            Assert.AreEqual(y2Expected, intersectionCoordinates[1].Y, Tolerance);
        }
 /// <summary>
 /// Returns points where the circular curve intersects the provided linear curve.
 /// </summary>
 /// <param name="otherLine">Linear curve that intersects the current linear curve.</param>
 /// <returns>CartesianCoordinate.</returns>
 public CartesianCoordinate[] IntersectionCoordinate(LinearCurve otherLine)
 {
     return(IntersectionLinearCircular.IntersectionCoordinates(otherLine, this));
 }