Example #1
0
  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);
  }
Example #2
0
  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;
  }
Example #3
0
  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));
  }
Example #4
0
 public int getComponentBitSize() {
   return componentBits.getBitSize();
 }