Example #1
0
        public static void X_Returns_X_Coordinates_Difference(double xI, double xJ, double xDifference)
        {
            CartesianOffset offset = new CartesianOffset(
                new CartesianCoordinate(xI, 0),
                new CartesianCoordinate(xJ, 0));

            Assert.AreEqual(xDifference, offset.X(), Tolerance);
        }
        /// <summary>
        /// The y-coordinates of a line intersecting a circle centered at 0,0.
        /// </summary>
        /// <param name="point1">First point forming the line.</param>
        /// <param name="point2">Second point forming the line.</param>
        /// <param name="radius">Radius of the circle centered at 0,0.</param>
        public static double[] CircleLineIntersectY(CartesianCoordinate point1, CartesianCoordinate point2, double radius)
        {
            CartesianOffset delta       = new CartesianOffset(point1, point2);
            double          determinant = point1.CrossProduct(point2);
            double          lineLength  = AlgebraLibrary.SRSS(delta.X(), delta.Y());
            double          incidence   = incidenceLineCircle(radius, lineLength, determinant);

            return(CircleLineIntersectY(radius, lineLength, incidence, determinant, delta));
        }
 /// <summary>
 /// The y-coordinates of a line intersecting a circle centered at 0,0.
 /// </summary>
 /// <param name="radius"></param>
 /// <param name="lineLength"></param>
 /// <param name="incidence"></param>
 /// <param name="determinant"></param>
 /// <param name="delta"></param>
 /// <returns></returns>
 public static double[] CircleLineIntersectY(
     double radius,
     double lineLength,
     double incidence,
     double determinant,
     CartesianOffset delta)
 {
     return((-determinant * delta.X() / lineLength.Squared()).PlusMinus(
                NMath.Abs(delta.Y()) * NMath.Sqrt(incidence) / lineLength.Squared()));
 }
Example #4
0
            /// <summary>
            /// Initializes a new instance of the <see cref="IntersectionProperties"/> class.
            /// </summary>
            /// <param name="linearCurve">The linear curve.</param>
            /// <param name="circularCurve">The circular curve.</param>
            public IntersectionProperties(LinearCurve linearCurve, CircularCurve circularCurve)
            {
                Tolerance       = Generics.GetTolerance(linearCurve, circularCurve);
                Transformations = new Transformations(circularCurve.LocalOrigin, new CartesianCoordinate(circularCurve.LocalOrigin.X + 1, circularCurve.LocalOrigin.Y));
                LinearCurve linearCurveLocal = transformToLocal(linearCurve);

                D = Numbers.ValueAsZeroIfWithinAbsoluteTolerance(linearCurveLocal.ControlPointI.CrossProduct(linearCurveLocal.ControlPointJ), Tolerance);
                CartesianOffset offset = linearCurveLocal.Range.End.Limit.OffsetFrom(linearCurveLocal.Range.Start.Limit);

                dx = offset.X();
                dy = offset.Y();
                dr = AlgebraLibrary.SRSS(dx, dy);

                IncidenceDelta = Numbers.ValueAsZeroIfWithinAbsoluteTolerance((circularCurve.Radius * dr).Squared() - D.Squared(), Tolerance);
            }