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 long toBits(Quatd q) { long x = componentBits.toBits((float) q.x); long y = componentBits.toBits((float) q.y); long z = componentBits.toBits((float) q.z); long w = componentBits.toBits((float) q.w); long result = x; result |= y << yShift; result |= z << zShift; result |= w << wShift; return result; }
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)); }
public int getComponentBitSize() { return componentBits.getBitSize(); }