Ejemplo n.º 1
0
        public static void Initialization()
        {
            LinearCurve   curve1 = new LinearCurve(new CartesianCoordinate(1, 2), new CartesianCoordinate(3, 4));
            CircularCurve curve2 = new CircularCurve(new CartesianCoordinate(-1, 2), new CartesianCoordinate(-3, 4));

            IntersectionLinearCircular intersections = new IntersectionLinearCircular(curve1, curve2);

            Assert.AreEqual(curve1, intersections.Curve1);
            Assert.AreEqual(curve2, intersections.Curve2);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        [TestCase(5, 13, 12, 6, 5, 6, 6, true)]  // Sloped Intersection in translated coordinates
        public static void AreIntersecting_Static(
            double x1, double y1, double x2, double y2,
            double x, double y, double r,
            bool expectedResult)
        {
            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;

            bool result = IntersectionLinearCircular.AreIntersecting(curve1, curve2);

            Assert.AreEqual(expectedResult, result);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 /// <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));
 }