Beispiel #1
0
        public static void DivideOverride_Divides_Coordinate_by_a_Scaling_Factor(double angleRadians, double factor, double scaledAngle)
        {
            AngularOffset offset    = new AngularOffset(new Angle(), new Angle(angleRadians));
            AngularOffset offsetNew = offset / factor;

            Assert.AreEqual(scaledAngle, offsetNew.Delta().Radians, 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);
        }
Beispiel #3
0
        public static void Delta_Returns_Angle_of_Rotation_Difference()
        {
            Angle         angle1 = new Angle(Numbers.PiOver2);
            Angle         angle2 = new Angle(Numbers.PiOver4);
            AngularOffset offset = new AngularOffset(angle1, angle2);

            Angle angleFromOffset = offset.Delta();

            Assert.AreEqual(-Numbers.PiOver4, angleFromOffset.Radians, Tolerance);
        }
Beispiel #4
0
        public static void MultiplyOverride_Multiplies_Coordinate_by_a_Scaling_Factor(double angleRadians, double factor, double scaledAngle)
        {
            AngularOffset offset = new AngularOffset(new Angle(), new Angle(angleRadians));

            AngularOffset offsetNew1 = offset * factor;

            Assert.AreEqual(scaledAngle, offsetNew1.Delta().Radians, Tolerance);

            AngularOffset offsetNew2 = factor * offset;

            Assert.AreEqual(scaledAngle, offsetNew2.Delta().Radians, Tolerance);
        }
Beispiel #5
0
        public static void AddOverride_Returns_Combined_Coordinates(double angleRadians1, double angleRadians2, double angleResult)
        {
            AngularOffset offset1 = new AngularOffset(new Angle(), new Angle(angleRadians1));
            AngularOffset offset2 = new AngularOffset(new Angle(), new Angle(angleRadians2));

            AngularOffset offset3 = offset1 + offset2;

            Assert.AreEqual(angleResult, offset3.Delta().Radians, Tolerance);

            AngularOffset offset4 = offset1 + angleRadians2;

            Assert.AreEqual(angleResult, offset4.Delta().Radians, Tolerance);

            AngularOffset offset5 = angleRadians1 + offset2;

            Assert.AreEqual(angleResult, offset5.Delta().Radians, Tolerance);
        }
Beispiel #6
0
        public static void SubtractOverride_Returns_Difference_of_Coordinates(double angleRadians1, double angleRadians2, double angleResult)
        {
            AngularOffset offset1 = new AngularOffset(new Angle(), new Angle(angleRadians1));
            AngularOffset offset2 = new AngularOffset(new Angle(), new Angle(angleRadians2));

            AngularOffset offset3 = offset1 - offset2;

            Assert.AreEqual(angleResult, offset3.Delta().Radians, Tolerance);

            AngularOffset offset4 = offset1 - angleRadians2;

            Assert.AreEqual(angleResult, offset4.Delta().Radians, Tolerance);

            AngularOffset offset5 = angleRadians1 - offset2;

            Assert.AreEqual(angleResult, offset5.Delta().Radians, Tolerance);
        }