예제 #1
0
 /// <summary>
 /// Test whether this object is equal to <paramref name="other"/> within a given <paramref name="tolerance"/>. Even if the
 /// two structures are not identical, this method will return <c>true</c> if they are 'close enough' (e.g. within the tolerance).
 /// </summary>
 /// <param name="other">The other Cylinder to test against.</param>
 /// <param name="tolerance">The amount of tolerance to give. For any floating-point component in both objects, if the difference
 /// between them is less than this value, they will be considered equal.</param>
 /// <returns>True if this object is equal to <paramref name="other"/> with the given <paramref name="tolerance"/>.</returns>
 public bool EqualsWithTolerance(Cylinder other, double tolerance)
 {
     Assure.GreaterThanOrEqualTo(tolerance, 0f, "Tolerance must not be negative.");
     return(Center.EqualsWithTolerance(other.Center, tolerance) &&
            Math.Abs(Height - other.Height) < tolerance &&
            Math.Abs(Radius - other.Radius) < tolerance);
 }
예제 #2
0
 /// <summary>
 /// Test whether this object is equal to <paramref name="other"/> within a given <paramref name="tolerance"/>. Even if the
 /// two structures are not identical, this method will return <c>true</c> if they are 'close enough' (e.g. within the tolerance).
 /// </summary>
 /// <param name="other">The other Vector3 to test against.</param>
 /// <param name="tolerance">The amount of tolerance to give. For any floating-point component in both objects, if the difference
 /// between them is less than this value, they will be considered equal.</param>
 /// <returns>True if this object is equal to <paramref name="other"/> with the given <paramref name="tolerance"/>.</returns>
 public bool EqualsWithTolerance(Vector3 other, double tolerance)
 {
     Assure.GreaterThanOrEqualTo(tolerance, 0f, "Tolerance must not be negative.");
     return(Math.Abs(X - other.X) < tolerance &&
            Math.Abs(Y - other.Y) < tolerance &&
            Math.Abs(Z - other.Z) < tolerance);
 }
예제 #3
0
 /// <summary>
 /// Test whether this object is equal to <paramref name="other"/> within a given <paramref name="tolerance"/>. Even if the
 /// two structures are not identical, this method will return <c>true</c> if they are 'close enough' (e.g. within the tolerance).
 /// </summary>
 /// <param name="other">The other Rectangle to test against.</param>
 /// <param name="tolerance">The amount of tolerance to give. For any floating-point component in both objects, if the difference
 /// between them is less than this value, they will be considered equal.</param>
 /// <returns>True if this object is equal to <paramref name="other"/> with the given <paramref name="tolerance"/>.</returns>
 public bool EqualsWithTolerance(Rectangle other, double tolerance)
 {
     Assure.GreaterThanOrEqualTo(tolerance, 0f, "Tolerance must not be negative.");
     return(BottomLeft.EqualsWithTolerance(other.BottomLeft, tolerance) &&
            Math.Abs(Width - other.Width) < tolerance &&
            Math.Abs(Height - other.Height) < tolerance);
 }
예제 #4
0
 /// <summary>
 /// Test whether this object is equal to <paramref name="other"/> within a given <paramref name="tolerance"/>. Even if the
 /// two structures are not identical, this method will return <c>true</c> if they are 'close enough' (e.g. within the tolerance).
 /// </summary>
 /// <param name="other">The other Cone to test against.</param>
 /// <param name="tolerance">The amount of tolerance to give. For any floating-point component in both objects, if the difference
 /// between them is less than this value, they will be considered equal.</param>
 /// <returns>True if this object is equal to <paramref name="other"/> with the given <paramref name="tolerance"/>.</returns>
 public bool EqualsWithTolerance(Cone other, double tolerance)
 {
     Assure.GreaterThanOrEqualTo(tolerance, 0f, "Tolerance must not be negative.");
     return(TopCenter.EqualsWithTolerance(other.TopCenter, tolerance) &&
            Math.Abs(TopRadius - other.TopRadius) < tolerance &&
            Math.Abs(BottomRadius - other.BottomRadius) < tolerance &&
            Math.Abs(Height - other.Height) < tolerance);
 }
예제 #5
0
 /// <summary>
 /// Test whether this object is equal to <paramref name="other"/> within a given <paramref name="tolerance"/>. Even if the
 /// two structures are not identical, this method will return <c>true</c> if they are 'close enough' (e.g. within the tolerance).
 /// </summary>
 /// <param name="other">The other Matrix to test against.</param>
 /// <param name="tolerance">The amount of tolerance to give. For any floating-point component in both objects, if the difference
 /// between them is less than this value, they will be considered equal.</param>
 /// <returns>True if this object is equal to <paramref name="other"/> with the given <paramref name="tolerance"/>.</returns>
 public bool EqualsWithTolerance(Matrix other, double tolerance)
 {
     Assure.GreaterThanOrEqualTo(tolerance, 0f, "Tolerance must not be negative.");
     return(RowA.EqualsWithTolerance(other.RowA, tolerance) &&
            RowB.EqualsWithTolerance(other.RowB, tolerance) &&
            RowC.EqualsWithTolerance(other.RowC, tolerance) &&
            RowD.EqualsWithTolerance(other.RowD, tolerance));
 }
예제 #6
0
 /// <summary>
 /// Test whether this object is equal to <paramref name="other"/> within a given <paramref name="tolerance"/>. Even if the
 /// two structures are not identical, this method will return <c>true</c> if they are 'close enough' (e.g. within the tolerance).
 /// </summary>
 /// <param name="other">The other Ray to test against.</param>
 /// <param name="tolerance">The amount of tolerance to give. For any floating-point component in both objects, if the difference
 /// between them is less than this value, they will be considered equal.</param>
 /// <returns>True if this object is equal to <paramref name="other"/> with the given <paramref name="tolerance"/>.</returns>
 public bool EqualsWithTolerance(Ray other, double tolerance)
 {
     Assure.GreaterThanOrEqualTo(tolerance, 0f, "Tolerance must not be negative.");
     return(IsInfiniteLength == other.IsInfiniteLength &&
            StartPoint.EqualsWithTolerance(other.StartPoint, tolerance) &&
            Orientation.EqualsWithTolerance(other.Orientation, tolerance) &&
            (IsInfiniteLength || (Math.Abs(Length - other.Length) < tolerance)));
 }
예제 #7
0
        public static void InsertAt <T>(this IList <T> @this, T indexObject, T elementToInsert)
        {
            if (@this == null)
            {
                throw new ArgumentNullException("this", "InsertAt called on a null IEnumerable<T>.");
            }

#if DEBUG
            int index = @this.IndexOf(indexObject);
            Assure.GreaterThanOrEqualTo(index, 0, "'IndexObject' element is not actually in list 'this'.");
            @this.Insert(index, elementToInsert);
#else
            @this.Insert(@this.IndexOf(indexObject), elementToInsert);
#endif
        }
예제 #8
0
        public void TestGreaterThanOrEqualTo()
        {
            // Define variables and constants
            const int THREE = 3;
            const int FOUR  = 4;

            // Set up context


            // Execute
            Assure.GreaterThanOrEqualTo(FOUR, THREE);
            Assure.GreaterThanOrEqualTo(FOUR, FOUR);
            try {
                Assure.GreaterThanOrEqualTo(THREE, FOUR);
                Assert.Fail();
            }
            catch (AssuranceFailedException) {
            }

            // Assert outcome
        }
예제 #9
0
 /// <summary>
 /// Test whether this object is equal to <paramref name="other"/> within a given <paramref name="tolerance"/>. Even if the
 /// two structures are not identical, this method will return <c>true</c> if they are 'close enough' (e.g. within the tolerance).
 /// </summary>
 /// <param name="other">The other Plane to test against.</param>
 /// <param name="tolerance">The amount of tolerance to give. For any floating-point component in both objects, if the difference
 /// between them is less than this value, they will be considered equal.</param>
 /// <returns>True if this object is equal to <paramref name="other"/> with the given <paramref name="tolerance"/>.</returns>
 public bool EqualsWithTolerance(Plane other, double tolerance)
 {
     Assure.GreaterThanOrEqualTo(tolerance, 0f, "Tolerance must not be negative.");
     return(Normal.EqualsWithTolerance(other.Normal, tolerance) &&
            Math.Abs(DistanceToOrigin - other.DistanceToOrigin) < tolerance);
 }