Quaternion with a translation vector
Beispiel #1
0
        public void SetFromVectors(Vec3 vx, Vec3 vy, Vec3 vz, Vec3 pos)
        {
            var m34 = new Matrix34();

            m34.M00 = vx.X; m34.M01 = vy.X; m34.M02 = vz.X; m34.M03 = pos.X;
            m34.M10 = vx.Y; m34.M11 = vy.Y; m34.M12 = vz.Y; m34.M13 = pos.Y;
            m34.M20 = vx.Z; m34.M21 = vy.Z; m34.M22 = vz.Z; m34.M23 = pos.Z;
            this    = new QuatT(m34);
        }
Beispiel #2
0
        public bool IsEquivalent(QuatT p, float epsilon = 0.05f)
        {
            var  q0 = p.Q;
            var  q1 = -p.Q;
            bool t0 = (Math.Abs(Q.V.X - q0.V.X) <= epsilon) && (Math.Abs(Q.V.Y - q0.V.Y) <= epsilon) && (Math.Abs(Q.V.Z - q0.V.Z) <= epsilon) && (Math.Abs(Q.W - q0.W) <= epsilon);
            bool t1 = (Math.Abs(Q.V.X - q1.V.X) <= epsilon) && (Math.Abs(Q.V.Y - q1.V.Y) <= epsilon) && (Math.Abs(Q.V.Z - q1.V.Z) <= epsilon) && (Math.Abs(Q.W - q1.W) <= epsilon);

            return((t0 | t1) && (Math.Abs(T.X - p.T.X) <= epsilon) && (Math.Abs(T.Y - p.T.Y) <= epsilon) && (Math.Abs(T.Z - p.T.Z) <= epsilon));
        }
Beispiel #3
0
        /*public bool IsValid()
         * {
         *  if (!T.IsValid()) return false;
         *  if (!Q.IsValid()) return false;
         *  return true;
         * }*/

        public void Nlerp(QuatT start, QuatT end, float amount)
        {
            var d = end.Q;

            if ((start.Q | d) < 0)
            {
                d = -d;
            }

            var vDiff = d.V - start.Q.V;

            Q.V = start.Q.V + (vDiff * amount);
            Q.W = start.Q.W + ((d.W - start.Q.W) * amount);

            Q.Normalize();

            vDiff = end.T - start.T;
            T     = start.T + (vDiff * amount);
        }
Beispiel #4
0
 /// <summary>
 /// Sets the absolute of the specified joint
 /// </summary>
 /// <param name="jointName">Name of the joint</param>
 /// <param name="absolute">New absolute</param>
 /// <param name="characterSlot">Slot containing the character</param>
 public void SetJointAbsolute(string jointName, QuatT absolute, int characterSlot = 0)
 {
     NativeEntityMethods.SetJointAbsolute(this.GetIEntity(), jointName, characterSlot, absolute);
 }
Beispiel #5
0
 public void SetFromVectors(Vec3 vx, Vec3 vy, Vec3 vz, Vec3 pos)
 {
     var m34 = new Matrix34();
     m34.M00 = vx.X; m34.M01 = vy.X; m34.M02 = vz.X; m34.M03 = pos.X;
     m34.M10 = vx.Y; m34.M11 = vy.Y; m34.M12 = vz.Y; m34.M13 = pos.Y;
     m34.M20 = vx.Z; m34.M21 = vy.Z; m34.M22 = vz.Z; m34.M23 = pos.Z;
     this = new QuatT(m34);
 }
Beispiel #6
0
        /*public bool IsValid()
        {
            if (!T.IsValid()) return false;
            if (!Q.IsValid()) return false;
            return true;
        }*/
        public void Nlerp(QuatT start, QuatT end, float amount)
        {
            var d = end.Q;
            if ((start.Q | d) < 0) { d = -d; }

            var vDiff = d.V - start.Q.V;

            Q.V = start.Q.V + (vDiff * amount);
            Q.W = start.Q.W + ((d.W - start.Q.W) * amount);

            Q.Normalize();

            vDiff = end.T - start.T;
            T = start.T + (vDiff * amount);
        }
Beispiel #7
0
 public bool IsEquivalent(QuatT p, float epsilon = 0.05f)
 {
     var q0 = p.Q;
     var q1 = -p.Q;
     bool t0 = (Math.Abs(Q.V.X - q0.V.X) <= epsilon) && (Math.Abs(Q.V.Y - q0.V.Y) <= epsilon) && (Math.Abs(Q.V.Z - q0.V.Z) <= epsilon) && (Math.Abs(Q.W - q0.W) <= epsilon);
     bool t1 = (Math.Abs(Q.V.X - q1.V.X) <= epsilon) && (Math.Abs(Q.V.Y - q1.V.Y) <= epsilon) && (Math.Abs(Q.V.Z - q1.V.Z) <= epsilon) && (Math.Abs(Q.W - q1.W) <= epsilon);
     return ((t0 | t1) && (Math.Abs(T.X - p.T.X) <= epsilon) && (Math.Abs(T.Y - p.T.Y) <= epsilon) && (Math.Abs(T.Z - p.T.Z) <= epsilon));
 }
Beispiel #8
0
 /// <summary>
 /// Sets the absolute of the specified joint
 /// </summary>
 /// <param name="jointName">Name of the joint</param>
 /// <param name="absolute">New absolute</param>
 /// <param name="characterSlot">Slot containing the character</param>
 public void SetJointAbsolute(string jointName, QuatT absolute, int characterSlot = 0)
 {
     NativeEntityMethods.SetJointAbsolute(this.GetIEntity(), jointName, characterSlot, absolute);
 }