public void TestFloor() { double d = 0; double s = 0; d = 0; s = 0; AssertEqual("floor ", 0, MathX.Floor(d, s)); d = 1; s = 0; AssertEqual("floor ", Double.NaN, MathX.Floor(d, s)); d = 0; s = 1; AssertEqual("floor ", 0, MathX.Floor(d, s)); d = -1; s = 0; AssertEqual("floor ", Double.NaN, MathX.Floor(d, s)); d = 0; s = -1; AssertEqual("floor ", 0, MathX.Floor(d, s)); d = 10; s = 1.11; AssertEqual("floor ", 9.99, MathX.Floor(d, s)); d = 11.12333; s = 0.03499; AssertEqual("floor ", 11.09183, MathX.Floor(d, s)); d = -11.12333; s = 0.03499; AssertEqual("floor ", Double.NaN, MathX.Floor(d, s)); d = 11.12333; s = -0.03499; AssertEqual("floor ", Double.NaN, MathX.Floor(d, s)); d = -11.12333; s = -0.03499; AssertEqual("floor ", -11.09183, MathX.Floor(d, s)); d = 100; s = 0.001; AssertEqual("floor ", 100, MathX.Floor(d, s)); d = -0.001; s = -9.99; AssertEqual("floor ", 0, MathX.Floor(d, s)); d = 4.42; s = 0.05; AssertEqual("floor ", 4.4, MathX.Floor(d, s)); d = 0.05; s = 4.42; AssertEqual("floor ", 0, MathX.Floor(d, s)); d = 0.6666; s = 3.33; AssertEqual("floor ", 0, MathX.Floor(d, s)); d = 2d / 3; s = 3.33; AssertEqual("floor ", 0, MathX.Floor(d, s)); }
public void LoadRoom(Direction direction) { if (nextRoom != null) { MoveNextRoom(direction); return; } Vector2 nextGridPosition = snappingCamera.WorldToGrid(currentRoom.transform.position) + direction.ToVector(); nextGridCell = MathX.Floor(nextGridPosition); nextRoom = Instantiate(GetRandomRoom(), snappingCamera.GridToWorld(nextGridPosition), Quaternion.identity); nextRoomDirection = direction; }
public void TestFloor() { double d = 0; double s = 0; d = 0; s = 0; AssertEquals("floor ", 0, MathX.Floor(d, s)); d = 1; s = 0; AssertEquals("floor ", Double.NaN, MathX.Floor(d, s)); d = 0; s = 1; AssertEquals("floor ", 0, MathX.Floor(d, s)); d = -1; s = 0; AssertEquals("floor ", Double.NaN, MathX.Floor(d, s)); d = 0; s = -1; AssertEquals("floor ", 0, MathX.Floor(d, s)); d = 10; s = 1.11; AssertEquals("floor ", 9.99, MathX.Floor(d, s)); d = 11.12333; s = 0.03499; AssertEquals("floor ", 11.09183, MathX.Floor(d, s)); d = -11.12333; s = 0.03499; AssertEquals("floor ", Double.NaN, MathX.Floor(d, s)); d = 11.12333; s = -0.03499; AssertEquals("floor ", Double.NaN, MathX.Floor(d, s)); d = -11.12333; s = -0.03499; AssertEquals("floor ", -11.09183, MathX.Floor(d, s)); d = 100; s = 0.001; AssertEquals("floor ", 100, MathX.Floor(d, s)); d = -0.001; s = -9.99; AssertEquals("floor ", 0, MathX.Floor(d, s)); d = 4.42; s = 0.05; AssertEquals("floor ", 4.4, MathX.Floor(d, s)); d = 0.05; s = 4.42; AssertEquals("floor ", 0, MathX.Floor(d, s)); d = 0.6666; s = 3.33; AssertEquals("floor ", 0, MathX.Floor(d, s)); d = 2d / 3; s = 3.33; AssertEquals("floor ", 0, MathX.Floor(d, s)); // samples from http://www.excelfunctions.net/Excel-Ceiling-Function.html // and https://support.office.com/en-us/article/CEILING-function-0a5cd7c8-0720-4f0a-bd2c-c943e510899f d = 3.7; s = 2; AssertEquals("floor ", 2, MathX.Floor(d, s)); d = -2.5; s = -2; AssertEquals("floor ", -2, MathX.Floor(d, s)); d = 2.5; s = -2; AssertEquals("floor ", Double.NaN, MathX.Floor(d, s)); d = 1.58; s = 0.1; AssertEquals("floor ", 1.5, MathX.Floor(d, s)); d = 0.234; s = 0.01; AssertEquals("floor ", 0.23, MathX.Floor(d, s)); }