Beispiel #1
0
        public static void LengthArc_Returns_Curve_Line_Distance_Between_Offset_Points_of_Specified_Radius(double angleRadians, double radius, double expectedResult)
        {
            Angle         angle1 = new Angle(0);
            Angle         angle2 = new Angle(angleRadians);
            AngularOffset offset = new AngularOffset(angle1, angle2);

            Assert.AreEqual(expectedResult, offset.LengthArc(radius), Tolerance);
        }
        //TODO Useful? Not used yet
        ///// <summary>
        ///// The length between the provided points along a circular curve, assumed to be about the origin.
        ///// </summary>
        ///// <param name="pointI">Point i.</param>
        ///// <param name="pointJ">Point j.</param>
        ///// <returns>System.Double.</returns>
        //public static double LengthBetween(CartesianCoordinate pointI, CartesianCoordinate pointJ)
        //{
        //    AngularOffset angle = AngularOffset.CreateFromPoints(pointI, CartesianCoordinate.Origin(), pointJ);
        //    double radius = pointI.OffsetFrom(CartesianCoordinate.Origin()).Length();
        //    return LengthBetween(angle, radius);
        //}

        ///// <summary>
        ///// The length between the provided points along a circular curve.
        ///// </summary>
        ///// <param name="pointI">Point i.</param>
        ///// <param name="pointJ">Point j.</param>
        ///// <param name="radius">Arc radius</param>
        ///// <returns>System.Double.</returns>
        //public static double LengthBetween(CartesianCoordinate pointI, CartesianCoordinate pointJ, double radius)
        //{
        //    IntersectionCircularCircular intersection = new IntersectionCircularCircular(
        //        new CircularCurve(radius, pointI),
        //        new CircularCurve(radius, pointJ));

        //    // Shape is symmetric, so it doesn't matter if the 1st or 2nd intersection coordinate is taken.
        //    CartesianCoordinate center = intersection.IntersectionCoordinates()[0];
        //    AngularOffset angle = AngularOffset.CreateFromPoints(pointI, center, pointJ);
        //    return LengthBetween(angle, radius);
        //}

        /// <summary>
        /// The length within the provided rotation along a circular curve.
        /// </summary>
        /// <param name="rotation">Rotation to get arc length between.</param>
        /// <param name="radius">Arc radius</param>
        /// <returns>System.Double.</returns>
        public static double LengthBetween(AngularOffset rotation, double radius)
        {
            double length = rotation.LengthArc(radius);

            return((length.IsZeroSign(rotation.Tolerance) && !rotation.Delta().Radians.IsZeroSign(rotation.Tolerance)) ?
                   Numbers.TwoPi * radius :
                   length);
        }