public static Coord3D get(int x, int y, int z) { return new Coord3D(x, y, z); } /**
/** * Returns the linear distance between this coordinate point and the * provided one. * * @param other * @return */ public double distance(Coord3D other) { return Math.sqrt(squareDistance(other)); }
public static Coord3D mortonDecode3D( int morton ) { // unpack 3 5-bit indices from a 15-bit Morton code int value1 = morton; int value2 = ( value1 >>> 1 ); int value3 = ( value1 >>> 2 ); value1 &= 0x00001249; value2 &= 0x00001249; value3 &= 0x00001249; value1 |= ( value1 >>> 2 ); value2 |= ( value2 >>> 2 ); value3 |= ( value3 >>> 2 ); value1 &= 0x000010c3; value2 &= 0x000010c3; value3 &= 0x000010c3; value1 |= ( value1 >>> 4 ); value2 |= ( value2 >>> 4 ); value3 |= ( value3 >>> 4 ); value1 &= 0x0000100f; value2 &= 0x0000100f; value3 &= 0x0000100f; value1 |= ( value1 >>> 8 ); value2 |= ( value2 >>> 8 ); value3 |= ( value3 >>> 8 ); value1 &= 0x0000001f; value2 &= 0x0000001f; value3 &= 0x0000001f; return new Coord3D(value1, value2, value3); } public static int mortonBitDecode3D( int morton )
denominator *= 5.0; return new Coord3D((int)(width * (Integer.reverse(index + 1) >>> 1) * 0x1p-31), (int)(resY * height), (int)(resZ * depth));
deltaz = az - (ax >> 1); while (true) { result.offer(new Coord3D(x, y, z)); if (x == endx) { return result; deltaz = az - (ay >> 1); while (true) { result.offer(new Coord3D(x, y, z)); if (y == endy) { return result; deltay = ay - (az >> 1); while (true) { result.offer(new Coord3D(x, y, z)); if (z == endz) { return result;
/** * Converts the provided color into a three dimensional coordinate point for * use in the Bresenham algorithms. * * @param color * @return */ private Coord3D scolorToCoord3D(SColor color) { return new Coord3D(MathUtils.floor(color.r * 255), MathUtils.floor(color.g * 255), MathUtils.floor(color.b * 255)); }
public Coord3D onUnitShape3D(double distance, IRNG rng) { int x = 0, y = 0, z = 0; switch (this) { case SQUARE: case DIAMOND: case CIRCLE: case ROUGH_CIRCLE: Coord p = onUnitShape(distance, rng); return new Coord3D(p.x, p.y, 0);//2D strategies case CUBE: x = rng.between((int) -distance, (int) distance + 1); y = rng.between((int) -distance, (int) distance + 1); z = rng.between((int) -distance, (int) distance + 1); break; case OCTAHEDRON: case SPHERE: do { x = rng.between((int) -distance, (int) distance + 1); y = rng.between((int) -distance, (int) distance + 1); z = rng.between((int) -distance, (int) distance + 1); } while (radius(x, y, z) > distance); } return new Coord3D(x, y, z); } public double volume2D(double radiusLength)