public bool Compare(ref idQuat a, float epsilon)
 {
     return (
         idMath.Fabs(x - a.x) <= epsilon &&
         idMath.Fabs(y - a.y) <= epsilon &&
         idMath.Fabs(z - a.z) <= epsilon &&
         idMath.Fabs(w - a.w) <= epsilon);
 }
 public bool Compare(ref idQuat a, float epsilon)
 {
     return(
         idMath.Fabs(x - a.x) <= epsilon &&
         idMath.Fabs(y - a.y) <= epsilon &&
         idMath.Fabs(z - a.z) <= epsilon &&
         idMath.Fabs(w - a.w) <= epsilon);
 }
        // Spherical linear interpolation between two quaternions.
        public idQuat Slerp(ref idQuat from, ref idQuat to, float t)
        {
            //float omega, cosom, sinom, scale0, scale1;
            if (t <= 0.0f)
            {
                this = from; return(this);
            }
            if (t >= 1.0f)
            {
                this = to; return(this);
            }
            if (from == to)
            {
                this = to; return(this);
            }
            float  cosom = from.x * to.x + from.y * to.y + from.z * to.z + from.w * to.w;
            idQuat temp;

            if (cosom < 0.0f)
            {
                temp  = -to;
                cosom = -cosom;
            }
            else
            {
                temp = to;
            }
            float scale0, scale1;

            if (1.0f - cosom > 1e-6f)
            {
#if false
                float omega = Math.Acos(cosom);
                float sinom = 1.0f / Math.Sin(omega);
                scale0 = idMath.Sin((1.0f - t) * omega) * sinom;
                scale1 = idMath.Sin(t * omega) * sinom;
#else
                scale0 = 1.0f - cosom * cosom;
                float sinom = idMath.InvSqrt(scale0);
                float omega = idMath.ATan16(scale0 * sinom, cosom);
                scale0 = idMath.Sin16((1.0f - t) * omega) * sinom;
                scale1 = idMath.Sin16(t * omega) * sinom;
#endif
            }
            else
            {
                scale0 = 1.0f - t;
                scale1 = t;
            }
            this = (from * scale0) + (temp * scale1);
            return(this);
        }
 public bool Compare(ref idQuat a) { return (x == a.x && y == a.y && z == a.z && w == a.w); }
 public idQuat opMul(idQuat a) { this = this * a; return this; }
 public idQuat opSub(idQuat a) { x -= a.x; y -= a.y; z -= a.z; w -= a.w; return this; }
 public idQuat opAdd(idQuat a) { x += a.x; y += a.y; z += a.z; w += a.w; return this; }
        // Spherical linear interpolation between two quaternions.
        public idQuat Slerp(ref idQuat from, ref idQuat to, float t)
        {
            //float omega, cosom, sinom, scale0, scale1;
            if (t <= 0.0f) { this = from; return this; }
            if (t >= 1.0f) { this = to; return this; }
            if (from == to) { this = to; return this; }
            float cosom = from.x * to.x + from.y * to.y + from.z * to.z + from.w * to.w;
            idQuat temp;
            if (cosom < 0.0f)
            {
                temp = -to;
                cosom = -cosom;
            }
            else
                temp = to;
            float scale0, scale1;
            if (1.0f - cosom > 1e-6f)
            {
#if false
                float omega = Math.Acos(cosom);
                float sinom = 1.0f / Math.Sin(omega);
                scale0 = idMath.Sin((1.0f - t) * omega) * sinom;
                scale1 = idMath.Sin(t * omega) * sinom;
#else
                scale0 = 1.0f - cosom * cosom;
                float sinom = idMath.InvSqrt(scale0);
                float omega = idMath.ATan16(scale0 * sinom, cosom);
                scale0 = idMath.Sin16((1.0f - t) * omega) * sinom;
                scale1 = idMath.Sin16(t * omega) * sinom;
#endif
            }
            else
            {
                scale0 = 1.0f - t;
                scale1 = t;
            }
            this = (from * scale0) + (temp * scale1);
            return this;
        }
 public bool Compare(ref idQuat a)
 {
     return(x == a.x && y == a.y && z == a.z && w == a.w);
 }
 public idQuat opMul(idQuat a)
 {
     this = this * a; return(this);
 }
 public idQuat opSub(idQuat a)
 {
     x -= a.x; y -= a.y; z -= a.z; w -= a.w; return(this);
 }
 public idQuat opAdd(idQuat a)
 {
     x += a.x; y += a.y; z += a.z; w += a.w; return(this);
 }