Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Scratchpad {
- @Test
- void noU() {
- Assertions.assertTrue(equalVector(new Vector(-0.5, -0.5, -0.5), getCenter(new Vector(-1, -1, -1))));
- Assertions.assertTrue(equalVector(new Vector(10.5, 10.5, 10.5), getCenter(new Vector(10, 10, 10))));
- }
- @Test
- void yesMe() {
- Assertions.assertTrue(equalVector(new Vector(-0.5, -0.5, -0.5), getBlockCenter(new Vector(-1, -1, -1))));
- Assertions.assertTrue(equalVector(new Vector(10.5, 10.5, 10.5), getBlockCenter(new Vector(10, 10, 10))));
- }
- public Vector getBlockCenter(Vector loc) {
- final Vector vec = new Vector(0.5, 0.5, 0.5);
- return loc.toBlockVector().add(vec);
- }
- boolean equalVector(Vector a, Vector b) {
- assert a.getX() == b.getX();
- assert a.getY() == b.getY();
- assert a.getZ() == b.getZ();
- return true;
- }
- public Vector getCenter(Vector loc) {
- double x = loc.getX();
- double y = loc.getY();
- double z = loc.getZ();
- if (x < 0 && z >= 0) {
- x = x + 0.5D;
- z = z + 0.5D;
- } else if (x >= 0 && z < 0) {
- x = x - 0.5D;
- z = z - 0.5D;
- } else {
- if (x < 0) {
- x = x - 0.5D;
- } else {
- x = x + 0.5D;
- }
- if (z < 0) {
- z = z - 0.5D;
- } else {
- z = z + 0.5D;
- }
- }
- return new Vector(x, y, z);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment