Exemplo n.º 1
0
        internal void FuzzyPointArray_WithEmptyArray_Throws()
        {
            // Arrange
            var points = new FuzzyPoint[] { };

            // Act
            // Assert
            Assert.Throws <ArgumentException>(() => Validate.FuzzyPointArray(points, nameof(points)));
        }
Exemplo n.º 2
0
        internal void InequalityOperator(double x1, double y1, double x2, double y2, bool areNotEqual)
        {
            // Arrange
            // Act
            var point1 = new FuzzyPoint(x1, y1);
            var point2 = new FuzzyPoint(x2, y2);

            // Assert
            Assert.Equal(point1 != point2, areNotEqual);
        }
Exemplo n.º 3
0
        internal void ToStringTest()
        {
            // Arrange
            var point1 = new FuzzyPoint(1, 1);

            // Act
            var result = point1.ToString();

            // Assert
            Assert.Equal("FuzzyPoint: 1, 1", result);
        }
Exemplo n.º 4
0
        internal void EuclideanNorm(double x, double y, double expectedNorm)
        {
            // Arrange
            var point = new FuzzyPoint(x, y);

            // Act
            var result = point.EuclideanNorm();

            // Assert
            Assert.Equal(expectedNorm, result);
        }
Exemplo n.º 5
0
        public U Get(float point)
        {
            FuzzyPoint p     = new FuzzyPoint(point, percision);
            int        index = points.BinarySearch(p);

            if (index >= 0)
            {
                return(mapping[index]);
            }
            return(default(U));
        }
Exemplo n.º 6
0
        internal void SquaredDistanceTo()
        {
            // Arrange
            var point1 = new FuzzyPoint(1, 0);
            var point2 = new FuzzyPoint(0, 0);

            // Act
            var result = point1.SquaredDistanceTo(point2);

            // Assert
            Assert.Equal(1, result);
        }
Exemplo n.º 7
0
        public bool TryGet(float point, out U output)
        {
            FuzzyPoint p     = new FuzzyPoint(point, percision);
            int        index = points.BinarySearch(p);

            if (index >= 0)
            {
                output = mapping[index];
                return(true);
            }
            output = default(U);
            return(false);
        }
Exemplo n.º 8
0
        public U GetOrInit(float point, Func <U> constructor)
        {
            FuzzyPoint p     = new FuzzyPoint(point, percision);
            int        index = points.BinarySearch(p);

            if (index < 0)
            {
                index = ~index;
                points.Insert(index, p);
                mapping.Insert(index, constructor());
            }
            return(mapping[index]);
        }
Exemplo n.º 9
0
        public (U, U, U) GetOrInitLanes(float point, Func <U> constructor)
        {
            FuzzyPoint p     = new FuzzyPoint(point, percision);
            int        index = points.BinarySearch(p);

            if (index < 0)
            {
                index = ~index;
                points.Insert(index, p);
                mapping.Insert(index, constructor());
            }
            return(GetTuple(index));
        }
Exemplo n.º 10
0
        public (U, U, U) GetLanes(float point)
        {
            FuzzyPoint p     = new FuzzyPoint(point, percision);
            int        index = points.BinarySearch(p);

            if (index >= 0)
            {
                return(GetTuple(index));
            }
            else
            {
                return(default(U), default(U), default(U));
            }
        }
Exemplo n.º 11
0
        internal void GetHashCodeTest()
        {
            // Arrange
            var point1 = new FuzzyPoint(0, 0);
            var point2 = new FuzzyPoint(1, 1);

            // Act
            var result1 = point1.GetHashCode();
            var result2 = point2.GetHashCode();

            // Assert
            Assert.Equal(9, result1);
            Assert.Equal(2145386505, result2);
        }
Exemplo n.º 12
0
        internal void FuzzyPointArray_WithMinYAboveMaxY_Throws()
        {
            // Arrange
            var points = new FuzzyPoint[]
            {
                new FuzzyPoint(2, 0.5),
                new FuzzyPoint(4, 0.5),                  // X out of sequence
                new FuzzyPoint(3, 1)
            };

            // Act
            // Assert
            Assert.Throws <ArgumentException>(() => Validate.FuzzyPointArray(points, nameof(points)));
        }
Exemplo n.º 13
0
        internal void DistanceTo(
            double point1x,
            double point1y,
            double point2x,
            double point2y)
        {
            // Arrange
            var point1 = new FuzzyPoint(point1x, point1y);
            var point2 = new FuzzyPoint(point2x, point2y);

            // Act
            var result = point1.DistanceTo(point2);

            // Assert
            Assert.Equal(0, result);
        }
Exemplo n.º 14
0
        public void Set(float point, U value)
        {
            FuzzyPoint p     = new FuzzyPoint(point, percision);
            int        index = points.BinarySearch(p);

            if (index >= 0)
            {
                mapping[index] = value;
            }
            else
            {
                index = ~index;
                points.Insert(index, p);
                mapping.Insert(index, value);
            }
        }
Exemplo n.º 15
0
        internal void GetMembership_WithVariousInputs_ReturnsExpectedResult(double x, double expected)
        {
            // Arrange
            var points = new FuzzyPoint[]
            {
                new FuzzyPoint(2, 0.5),
                new FuzzyPoint(3, 1)
            };

            var function = new PiecewiseLinearFunction(points);

            // Act
            var result = function.GetMembership(x);

            // Assert
            Assert.Equal(UnitInterval.Create(expected), result);
        }
Exemplo n.º 16
0
        internal void MaxY_ReturnsExpectedResult()
        {
            // Arrange
            // Arrange
            var points = new FuzzyPoint[]
            {
                new FuzzyPoint(2, 0),
                new FuzzyPoint(3, 1)
            };

            var function = new PiecewiseLinearFunction(points);

            // Act
            var result = function.MaxY;

            // Assert
            Assert.Equal(UnitInterval.One(), result);
        }
Exemplo n.º 17
0
        internal void LowerBound_ReturnsExpectedResult()
        {
            // Arrange
            // Arrange
            var points = new FuzzyPoint[]
            {
                new FuzzyPoint(2, 0.5),
                new FuzzyPoint(3, 1)
            };

            var function = new PiecewiseLinearFunction(points);

            // Act
            var result = function.LowerBound;

            // Assert
            Assert.Equal(2, result);
        }
Exemplo n.º 18
0
        internal void Divide(
            double point1x,
            double point1y,
            double factor,
            double point2x,
            double point2y)
        {
            // Arrange
            var point = new FuzzyPoint(point1x, point1y);

            // Act
            var result1 = point.Divide(factor);
            var result2 = point / factor;

            // Assert
            Assert.Equal(new FuzzyPoint(point2x, point2y), result1);
            Assert.Equal(new FuzzyPoint(point2x, point2y), result2);
        }
Exemplo n.º 19
0
        internal void Subtract(
            double point1x,
            double point1y,
            double point2x,
            double point2y,
            double point3x,
            double point3y)
        {
            // Arrange
            var point1 = new FuzzyPoint(point1x, point1y);
            var point2 = new FuzzyPoint(point2x, point2y);

            // Act
            var result1 = point1.Subtract(point2);
            var result2 = point1 - point2;

            // Assert
            Assert.Equal(new FuzzyPoint(point3x, point3y), result1);
            Assert.Equal(new FuzzyPoint(point3x, point3y), result2);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SingletonFunction"/> class.
        /// </summary>
        /// <param name="point">
        /// The point.
        /// </param>
        private SingletonFunction(FuzzyPoint point)
        {
            Validate.NotNull(point, nameof(point));

            this.points = new FuzzyPoint[] { point };
        }
Exemplo n.º 21
0
 public PlanarKey(XYZ norm, XYZ origin)
 {
     m_Norm = new FuzzyPoint(norm);
     m_Origin = new FuzzyPoint(origin);
 }