/// <summary>
 /// The x-coordinates of a line intersecting a circle centered at 0,0.
 /// </summary>
 /// <param name="radius">>Radius of the circle centered at 0,0.</param>
 /// <param name="lineLength"></param>
 /// <param name="incidence"></param>
 /// <param name="determinant"></param>
 /// <param name="delta"></param>
 /// <returns></returns>
 public static double[] CircleLineIntersectX(
     double radius,
     double lineLength,
     double incidence,
     double determinant,
     CartesianOffset delta)
 {
     return((determinant * delta.Y() / lineLength.Squared()).PlusMinus(
                NMath.Sign(delta.Y()) * delta.X() * NMath.Sqrt(incidence) / lineLength.Squared()));
 }
示例#2
0
        public static void Y_Returns_Y_Coordinates_Difference(double yI, double yJ, double yDifference)
        {
            CartesianOffset offset = new CartesianOffset(
                new CartesianCoordinate(0, yI),
                new CartesianCoordinate(0, yJ));

            Assert.AreEqual(yDifference, offset.Y(), 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));
        }
示例#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);
            }