internal void FuzzyPointArray_WithEmptyArray_Throws() { // Arrange var points = new FuzzyPoint[] { }; // Act // Assert Assert.Throws <ArgumentException>(() => Validate.FuzzyPointArray(points, nameof(points))); }
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); }
internal void ToStringTest() { // Arrange var point1 = new FuzzyPoint(1, 1); // Act var result = point1.ToString(); // Assert Assert.Equal("FuzzyPoint: 1, 1", result); }
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); }
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)); }
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); }
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); }
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]); }
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)); }
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)); } }
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); }
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))); }
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); }
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); } }
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); }
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); }
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); }
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); }
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); }
/// <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 }; }
public PlanarKey(XYZ norm, XYZ origin) { m_Norm = new FuzzyPoint(norm); m_Origin = new FuzzyPoint(origin); }