Exemplo n.º 1
0
        public void TestSanity()
        {
            // AreEqual
            {
                float x = 1.0f;
                float y = 2.0f;
                float z = x + y;

                Assert.IsTrue(FloatComparer.AreEqual(z, 3.0f));
            }

            // IsGreaterThan
            {
                float x = 1.001f;
                float y = 1.0f;

                Assert.IsTrue(FloatComparer.IsGreaterThan(x, y));
            }

            // IsLessThan
            {
                float x = 1.001f;
                float y = 1.0f;

                Assert.IsTrue(FloatComparer.IsLessThan(y, x));
            }
        }
Exemplo n.º 2
0
        public bool IsOrthogonalTo(DicomImagePlane other, float angleTolerance)
        {
            angleTolerance = Math.Abs(angleTolerance);
            float upper = (float)Math.PI / 2 + angleTolerance;
            float lower = (float)Math.PI / 2 - angleTolerance;

            float angle = GetAngleBetween(other);

            return(FloatComparer.IsGreaterThan(angle, lower) && FloatComparer.IsLessThan(angle, upper));
        }
Exemplo n.º 3
0
        private static void AssertDoublePrecisionConsistency(CompareResult expectedResult, double x, double y, string message, params object[] args)
        {
            var expectedAreEqual      = expectedResult == CompareResult.AreEqual;
            var expectedIsGreaterThan = expectedResult == CompareResult.GreaterThan;
            var expectedIsLessThan    = expectedResult == CompareResult.LessThan;

            var actualResult        = FloatComparer.Compare(x, y, 100);
            var actualAreEqual      = FloatComparer.AreEqual(x, y);
            var actualIsGreaterThan = FloatComparer.IsGreaterThan(x, y);
            var actualIsLessThan    = FloatComparer.IsLessThan(x, y);

            Assert.AreEqual((int)expectedResult, actualResult, message + " [Compare/double]", args);
            Assert.AreEqual(expectedAreEqual, actualAreEqual, message + " [AreEqual/double]", args);
            Assert.AreEqual(expectedIsGreaterThan, actualIsGreaterThan, message + " [IsGreaterThan/double]", args);
            Assert.AreEqual(expectedIsLessThan, actualIsLessThan, message + " [IsLessThan/double]", args);
        }
Exemplo n.º 4
0
        private static float ScaleToFit(Size source, SizeF destination)
        {
            if (source.Width == 0 || source.Height == 0)
            {
                return(1);
            }

            float aW = destination.Width / source.Width;
            float aH = destination.Height / source.Height;

            if (!FloatComparer.IsGreaterThan(aW * source.Height, destination.Height))
            {
                return(aW);
            }
            else
            {
                return(aH);
            }
        }
Exemplo n.º 5
0
        public bool IsParallelTo(DicomImagePlane other, float angleTolerance)
        {
            angleTolerance = Math.Abs(angleTolerance);
            float upper = angleTolerance;
            float lower = -angleTolerance;

            float angle = GetAngleBetween(other);

            bool parallel = FloatComparer.IsGreaterThan(angle, lower) && FloatComparer.IsLessThan(angle, upper);

            if (!parallel)
            {
                upper    = (float)Math.PI + angleTolerance;
                lower    = (float)Math.PI - angleTolerance;
                parallel = FloatComparer.IsGreaterThan(angle, lower) && FloatComparer.IsLessThan(angle, upper);
            }

            return(parallel);
        }