public Quatd fromBits(long bits) { long x = bits & componentBits.getMask(); long y = (bits >> yShift) & componentBits.getMask(); long z = (bits >> zShift) & componentBits.getMask(); long w = (bits >> wShift) & componentBits.getMask(); float xf = componentBits.fromBits(x); float yf = componentBits.fromBits(y); float zf = componentBits.fromBits(z); float wf = componentBits.fromBits(w); return new Quatd(xf, yf, zf, wf); }
public QuatBits(int componentBitSize) { this.componentBits = new FloatBits(-1, 1, componentBitSize); this.yShift = componentBitSize; this.zShift = yShift + componentBitSize; this.wShift = zShift + componentBitSize; this.totalBits = wShift + componentBitSize; if (totalBits > 64) { throw new IllegalArgumentException("Total bit size exceeds 64"); } this.mask = componentBits.getMask(); mask |= componentBits.getMask() << yShift; mask |= componentBits.getMask() << zShift; mask |= componentBits.getMask() << wShift; System.out.println("Bit size:" + totalBits + " mask:" + Long.toHexString(mask)); }