示例#1
0
        public static Vector4D Clamp(Vector4D value1, Vector4D min, Vector4D max)
        {
            Vector4D vectord;
            double   x     = value1.X;
            double   num2  = (x > max.X) ? max.X : x;
            double   num3  = (num2 < min.X) ? min.X : num2;
            double   y     = value1.Y;
            double   num5  = (y > max.Y) ? max.Y : y;
            double   num6  = (num5 < min.Y) ? min.Y : num5;
            double   z     = value1.Z;
            double   num8  = (z > max.Z) ? max.Z : z;
            double   num9  = (num8 < min.Z) ? min.Z : num8;
            double   w     = value1.W;
            double   num11 = (w > max.W) ? max.W : w;
            double   num12 = (num11 < min.W) ? min.W : num11;

            vectord.X = num3;
            vectord.Y = num6;
            vectord.Z = num9;
            vectord.W = num12;
            return(vectord);
        }
示例#2
0
        public static void Transform(ref Vector4D value, ref Quaternion rotation, out Vector4D result)
        {
            double num   = rotation.X + rotation.X;
            double num2  = rotation.Y + rotation.Y;
            double num3  = rotation.Z + rotation.Z;
            double num4  = rotation.W * num;
            double num5  = rotation.W * num2;
            double num6  = rotation.W * num3;
            double num7  = rotation.X * num;
            double num8  = rotation.X * num2;
            double num9  = rotation.X * num3;
            double num10 = rotation.Y * num2;
            double num11 = rotation.Y * num3;
            double num12 = rotation.Z * num3;
            double num13 = ((value.X * ((1.0 - num10) - num12)) + (value.Y * (num8 - num6))) + (value.Z * (num9 + num5));
            double num14 = ((value.X * (num8 + num6)) + (value.Y * ((1.0 - num7) - num12))) + (value.Z * (num11 - num4));
            double num15 = ((value.X * (num9 - num5)) + (value.Y * (num11 + num4))) + (value.Z * ((1.0 - num7) - num10));

            result.X = num13;
            result.Y = num14;
            result.Z = num15;
            result.W = value.W;
        }
 public static QuaternionD FromVector4(Vector4D v)
 {
     return(new QuaternionD(v.X, v.Y, v.Z, v.W));
 }
 public static QuaternionD FromVector4(Vector4D v) =>
 new QuaternionD(v.X, v.Y, v.Z, v.W);
示例#5
0
        public static void Hermite(ref Vector4D value1, ref Vector4D tangent1, ref Vector4D value2, ref Vector4D tangent2, double amount, out Vector4D result)
        {
            double num  = amount * amount;
            double num2 = amount * num;
            double num3 = ((2.0 * num2) - (3.0 * num)) + 1.0;
            double num4 = (-2.0 * num2) + (3.0 * num);
            double num5 = (num2 - (2.0 * num)) + amount;
            double num6 = num2 - num;

            result.X = (((value1.X * num3) + (value2.X * num4)) + (tangent1.X * num5)) + (tangent2.X * num6);
            result.Y = (((value1.Y * num3) + (value2.Y * num4)) + (tangent1.Y * num5)) + (tangent2.Y * num6);
            result.Z = (((value1.Z * num3) + (value2.Z * num4)) + (tangent1.Z * num5)) + (tangent2.Z * num6);
            result.W = (((value1.W * num3) + (value2.W * num4)) + (tangent1.W * num5)) + (tangent2.W * num6);
        }
示例#6
0
        public static Vector4D Hermite(Vector4D value1, Vector4D tangent1, Vector4D value2, Vector4D tangent2, double amount)
        {
            Vector4D vectord;
            double   num  = amount * amount;
            double   num2 = amount * num;
            double   num3 = ((2.0 * num2) - (3.0 * num)) + 1.0;
            double   num4 = (-2.0 * num2) + (3.0 * num);
            double   num5 = (num2 - (2.0 * num)) + amount;
            double   num6 = num2 - num;

            vectord.X = (((value1.X * num3) + (value2.X * num4)) + (tangent1.X * num5)) + (tangent2.X * num6);
            vectord.Y = (((value1.Y * num3) + (value2.Y * num4)) + (tangent1.Y * num5)) + (tangent2.Y * num6);
            vectord.Z = (((value1.Z * num3) + (value2.Z * num4)) + (tangent1.Z * num5)) + (tangent2.Z * num6);
            vectord.W = (((value1.W * num3) + (value2.W * num4)) + (tangent1.W * num5)) + (tangent2.W * num6);
            return(vectord);
        }
示例#7
0
        public static void CatmullRom(ref Vector4D value1, ref Vector4D value2, ref Vector4D value3, ref Vector4D value4, double amount, out Vector4D result)
        {
            double num  = amount * amount;
            double num2 = amount * num;

            result.X = 0.5 * ((((2.0 * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2.0 * value1.X) - (5.0 * value2.X)) + (4.0 * value3.X)) - value4.X) * num)) + ((((-value1.X + (3.0 * value2.X)) - (3.0 * value3.X)) + value4.X) * num2));
            result.Y = 0.5 * ((((2.0 * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2.0 * value1.Y) - (5.0 * value2.Y)) + (4.0 * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3.0 * value2.Y)) - (3.0 * value3.Y)) + value4.Y) * num2));
            result.Z = 0.5 * ((((2.0 * value2.Z) + ((-value1.Z + value3.Z) * amount)) + (((((2.0 * value1.Z) - (5.0 * value2.Z)) + (4.0 * value3.Z)) - value4.Z) * num)) + ((((-value1.Z + (3.0 * value2.Z)) - (3.0 * value3.Z)) + value4.Z) * num2));
            result.W = 0.5 * ((((2.0 * value2.W) + ((-value1.W + value3.W) * amount)) + (((((2.0 * value1.W) - (5.0 * value2.W)) + (4.0 * value3.W)) - value4.W) * num)) + ((((-value1.W + (3.0 * value2.W)) - (3.0 * value3.W)) + value4.W) * num2));
        }
示例#8
0
        public static Vector4D CatmullRom(Vector4D value1, Vector4D value2, Vector4D value3, Vector4D value4, double amount)
        {
            Vector4D vectord;
            double   num  = amount * amount;
            double   num2 = amount * num;

            vectord.X = 0.5 * ((((2.0 * value2.X) + ((-value1.X + value3.X) * amount)) + (((((2.0 * value1.X) - (5.0 * value2.X)) + (4.0 * value3.X)) - value4.X) * num)) + ((((-value1.X + (3.0 * value2.X)) - (3.0 * value3.X)) + value4.X) * num2));
            vectord.Y = 0.5 * ((((2.0 * value2.Y) + ((-value1.Y + value3.Y) * amount)) + (((((2.0 * value1.Y) - (5.0 * value2.Y)) + (4.0 * value3.Y)) - value4.Y) * num)) + ((((-value1.Y + (3.0 * value2.Y)) - (3.0 * value3.Y)) + value4.Y) * num2));
            vectord.Z = 0.5 * ((((2.0 * value2.Z) + ((-value1.Z + value3.Z) * amount)) + (((((2.0 * value1.Z) - (5.0 * value2.Z)) + (4.0 * value3.Z)) - value4.Z) * num)) + ((((-value1.Z + (3.0 * value2.Z)) - (3.0 * value3.Z)) + value4.Z) * num2));
            vectord.W = 0.5 * ((((2.0 * value2.W) + ((-value1.W + value3.W) * amount)) + (((((2.0 * value1.W) - (5.0 * value2.W)) + (4.0 * value3.W)) - value4.W) * num)) + ((((-value1.W + (3.0 * value2.W)) - (3.0 * value3.W)) + value4.W) * num2));
            return(vectord);
        }
示例#9
0
 public static void SmoothStep(ref Vector4D value1, ref Vector4D value2, double amount, out Vector4D result)
 {
     amount   = (amount > 1.0) ? 1.0 : ((amount < 0.0) ? 0.0 : amount);
     amount   = (amount * amount) * (3.0 - (2.0 * amount));
     result.X = value1.X + ((value2.X - value1.X) * amount);
     result.Y = value1.Y + ((value2.Y - value1.Y) * amount);
     result.Z = value1.Z + ((value2.Z - value1.Z) * amount);
     result.W = value1.W + ((value2.W - value1.W) * amount);
 }
示例#10
0
 public static void Barycentric(ref Vector4D value1, ref Vector4D value2, ref Vector4D value3, double amount1, double amount2, out Vector4D result)
 {
     result.X = (value1.X + (amount1 * (value2.X - value1.X))) + (amount2 * (value3.X - value1.X));
     result.Y = (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2 * (value3.Y - value1.Y));
     result.Z = (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2 * (value3.Z - value1.Z));
     result.W = (value1.W + (amount1 * (value2.W - value1.W))) + (amount2 * (value3.W - value1.W));
 }
示例#11
0
 public static void Lerp(ref Vector4D value1, ref Vector4D value2, double amount, out Vector4D result)
 {
     result.X = value1.X + ((value2.X - value1.X) * amount);
     result.Y = value1.Y + ((value2.Y - value1.Y) * amount);
     result.Z = value1.Z + ((value2.Z - value1.Z) * amount);
     result.W = value1.W + ((value2.W - value1.W) * amount);
 }
示例#12
0
        public static void Clamp(ref Vector4D value1, ref Vector4D min, ref Vector4D max, out Vector4D result)
        {
            double x     = value1.X;
            double num2  = (x > max.X) ? max.X : x;
            double num3  = (num2 < min.X) ? min.X : num2;
            double y     = value1.Y;
            double num5  = (y > max.Y) ? max.Y : y;
            double num6  = (num5 < min.Y) ? min.Y : num5;
            double z     = value1.Z;
            double num8  = (z > max.Z) ? max.Z : z;
            double num9  = (num8 < min.Z) ? min.Z : num8;
            double w     = value1.W;
            double num11 = (w > max.W) ? max.W : w;
            double num12 = (num11 < min.W) ? min.W : num11;

            result.X = num3;
            result.Y = num6;
            result.Z = num9;
            result.W = num12;
        }
示例#13
0
        public static MatrixD UnpackOrthoMatrix(ref Vector4D packed)
        {
            int w = (int)packed.W;

            return(MatrixD.CreateWorld(new Vector3((Vector4)packed), Base6Directions.GetVector((int)(w / 6)), Base6Directions.GetVector((int)(w % 6))));
        }