示例#1
0
文件: Quat4d.java 项目: j3d/j3dtools
  /**
   * Get the value of this quaternion as an axis-angle value.
   *
   * @param aa The axis angle object to put the converted values into
   */
  public void get(AxisAngle4d aa) {
    double d = x * x + y * y + z * z;

    if (d > EPSILON) {
      d = Math.sqrt(d);
      double inv_d = 1 / d;

      aa.x = x * inv_d;
      aa.y = y * inv_d;
      aa.z = z * inv_d;
      aa.angle = 2 * Math.atan2(d, angle);
    } else {
      aa.x = 0.0f;
      aa.y = 1.0f;
      aa.z = 0.0f;
      aa.angle = 0.0f;
    }
  }