@Override // from interface IVector public float angleBetween (IVector other) { float cos = dot(other) / (length() * other.length()); return cos >= 1f ? 0f : FloatMath.acos(cos); }
@Override // from interface IVector public float angleBetween (IVector other) { float cos = dot(other) / (length() * other.length()); return cos >= 1f ? 0f : FloatMath.acos(cos); }
@Override // from interface IVector3 public float angle (IVector3 other) { return FloatMath.acos(dot(other) / (length() * other.length())); }
@Override // from interface IVector3 public float angle (IVector3 other) { return FloatMath.acos(dot(other) / (length() * other.length())); }
/** * Sets this quaternion to the rotation of (0, 0, -1) onto the supplied normalized vector. * * @return a reference to the quaternion, for chaining. */ public Quaternion fromVectorFromNegativeZ (float tx, float ty, float tz) { float angle = FloatMath.acos(-tz); if (angle < MathUtil.EPSILON) { return set(IDENTITY); } if (angle > FloatMath.PI - MathUtil.EPSILON) { return set(0f, 1f, 0f, 0f); // 180 degrees about y } float len = FloatMath.hypot(tx, ty); return fromAngleAxis(angle, ty/len, -tx/len, 0f); }
/** * Sets this quaternion to the rotation of (0, 0, -1) onto the supplied normalized vector. * * @return a reference to the quaternion, for chaining. */ public Quaternion fromVectorFromNegativeZ (float tx, float ty, float tz) { float angle = FloatMath.acos(-tz); if (angle < MathUtil.EPSILON) { return set(IDENTITY); } if (angle > FloatMath.PI - MathUtil.EPSILON) { return set(0f, 1f, 0f, 0f); // 180 degrees about y } float len = FloatMath.hypot(tx, ty); return fromAngleAxis(angle, ty/len, -tx/len, 0f); }
@Override // from IQuaternion public Quaternion slerp (IQuaternion other, float t, Quaternion result) { float ox = other.x(), oy = other.y(), oz = other.z(), ow = other.w(); float cosa = x*ox + y*oy + z*oz + w*ow, s0, s1; // adjust signs if necessary if (cosa < 0f) { cosa = -cosa; ox = -ox; oy = -oy; oz = -oz; ow = -ow; } // calculate coefficients; if the angle is too close to zero, we must fall back // to linear interpolation if ((1f - cosa) > MathUtil.EPSILON) { float angle = FloatMath.acos(cosa), sina = FloatMath.sin(angle); s0 = FloatMath.sin((1f - t) * angle) / sina; s1 = FloatMath.sin(t * angle) / sina; } else { s0 = 1f - t; s1 = t; } return result.set(s0*x + s1*ox, s0*y + s1*oy, s0*z + s1*oz, s0*w + s1*ow); }
float t = FloatMath.acos(R / FloatMath.sqrt(Q3)) / 3f; float p = 2f * FloatMath.PI / 3f; float m = -2f * FloatMath.sqrt(Q);
@Override // from IQuaternion public Quaternion slerp (IQuaternion other, float t, Quaternion result) { float ox = other.x(), oy = other.y(), oz = other.z(), ow = other.w(); float cosa = x*ox + y*oy + z*oz + w*ow, s0, s1; // adjust signs if necessary if (cosa < 0f) { cosa = -cosa; ox = -ox; oy = -oy; oz = -oz; ow = -ow; } // calculate coefficients; if the angle is too close to zero, we must fall back // to linear interpolation if ((1f - cosa) > MathUtil.EPSILON) { float angle = FloatMath.acos(cosa), sina = FloatMath.sin(angle); s0 = FloatMath.sin((1f - t) * angle) / sina; s1 = FloatMath.sin(t * angle) / sina; } else { s0 = 1f - t; s1 = t; } return result.set(s0*x + s1*ox, s0*y + s1*oy, s0*z + s1*oz, s0*w + s1*ow); }
float t = FloatMath.acos(R / FloatMath.sqrt(Q3)) / 3f; float p = 2f * FloatMath.PI / 3f; float m = -2f * FloatMath.sqrt(Q);