Esempio n. 1
0
 public static Number4 Multiply(ref Number4 left, ref Number4 right)
 {
     return(new Number4(
                left.X * right.X,
                left.Y * right.Y,
                left.Z * right.Z,
                left.W * right.W));
 }
Esempio n. 2
0
 public static Number4 Swizzle(Number4 original, Operand4ComponentName[] swizzles)
 {
     return(new Number4(
                original.GetNumber((int)swizzles[0]),
                original.GetNumber((int)swizzles[1]),
                original.GetNumber((int)swizzles[2]),
                original.GetNumber((int)swizzles[3])));
 }
Esempio n. 3
0
 public static Number4 Lerp(ref Number4 left, ref Number4 right, float value)
 {
     return(new Number4(
                left.X * (1 - value) + right.X * value,
                left.Y * (1 - value) + right.Y * value,
                left.Z * (1 - value) + right.Z * value,
                left.W * (1 - value) + right.W * value));
 }
Esempio n. 4
0
 public static Number4 Average(ref Number4 v0, ref Number4 v1, ref Number4 v2, ref Number4 v3)
 {
     return(new Number4(
                (v0.X + v1.X + v2.X + v3.X) / 4.0f,
                (v0.Y + v1.Y + v2.Y + v3.Y) / 4.0f,
                (v0.Z + v1.Z + v2.Z + v3.Z) / 4.0f,
                (v0.W + v1.W + v2.W + v3.W) / 4.0f));
 }
Esempio n. 5
0
 public static Number4 Subtract(ref Number4 left, ref Number4 right)
 {
     return(new Number4(
                Number.FromFloat(left.Number0.Float - right.Number0.Float),
                Number.FromFloat(left.Number1.Float - right.Number1.Float),
                Number.FromFloat(left.Number2.Float - right.Number2.Float),
                Number.FromFloat(left.Number3.Float - right.Number3.Float)));
 }
Esempio n. 6
0
 public static Number4 Saturate(Number4 original)
 {
     return(new Number4
     {
         Number0 = Number.FromFloat(original.Number0.Float, true),
         Number1 = Number.FromFloat(original.Number1.Float, true),
         Number2 = Number.FromFloat(original.Number2.Float, true),
         Number3 = Number.FromFloat(original.Number3.Float, true)
     });
 }
Esempio n. 7
0
        public static Number4 Negate(Number4 original, NumberType type)
        {
            switch (type)
            {
            case NumberType.Float:
                return(NegateFloat(original));

            case NumberType.Int:
                return(NegateInt(original));

            case NumberType.Double:
                return(NegateDouble(original));

            default:
                throw new InvalidOperationException(string.Format("Negate is not a valid operation for number type '{0}'.", type));
            }
        }
Esempio n. 8
0
 public void WriteMaskedValue(Number4 value, ComponentMask mask)
 {
     if (mask.HasFlag(ComponentMask.X))
     {
         Number0 = value.Number0;
     }
     if (mask.HasFlag(ComponentMask.Y))
     {
         Number1 = value.Number1;
     }
     if (mask.HasFlag(ComponentMask.Z))
     {
         Number2 = value.Number2;
     }
     if (mask.HasFlag(ComponentMask.W))
     {
         Number3 = value.Number3;
     }
 }
Esempio n. 9
0
        public static Number4 Abs(Number4 original, NumberType type)
        {
            switch (type)
            {
            case NumberType.Float:
            case NumberType.Int:
            case NumberType.UInt:
                return(new Number4(
                           Number.Abs(original.Number0, type),
                           Number.Abs(original.Number1, type),
                           Number.Abs(original.Number2, type),
                           Number.Abs(original.Number3, type)));

            case NumberType.Double:
                return(new Number4(
                           Math.Abs(original.Double0),
                           Math.Abs(original.Double1)));

            default:
                throw new InvalidOperationException(string.Format("Abs is not a valid operation for number type '{0}'.", type));
            }
        }
Esempio n. 10
0
 public static Number4 Invert(ref Number4 value)
 {
     return(new Number4(1 - value.R, 1 - value.G, 1 - value.B, 1 - value.A));
 }
Esempio n. 11
0
 public static Number4 NegateInt(Number4 original)
 {
     return(new Number4(-original.Int0, -original.Int1, -original.Int2, -original.Int3));
 }
Esempio n. 12
0
 public static Number4 NegateFloat(Number4 original)
 {
     return(new Number4(-original.Float0, -original.Float1, -original.Float2, -original.Float3));
 }
Esempio n. 13
0
 public static Number4 NegateDouble(Number4 original)
 {
     return(new Number4(-original.Double0, -original.Double1));
 }