Пример #1
0
        static int Main(string[] args)
        {
            Point a = new Point(10, 50, 0, -100);
            Point b = new Point(10);
            Point c = Point.Max(a, b);

            if (((int)c.Y) != 50 || ((int)c.W) != 10)
            {
                return(0);
            }
            Point d = Point.Min(a, b);
            Point q = Point.Min(d, d);

            if (q != d)
            {
                return(0);
            }
            if (((int)d.W) != -100)
            {
                return(0);
            }
            return(100);
        }
Пример #2
0
        public static Vec3 ComputePrincipleComponent(Sym3x3 matrix)
        {
            Vec4 row0 = new Vec4(matrix[0], matrix[1], matrix[2], 0.0f);
            Vec4 row1 = new Vec4(matrix[1], matrix[3], matrix[4], 0.0f);
            Vec4 row2 = new Vec4(matrix[2], matrix[4], matrix[5], 0.0f);
            Vec4 v    = new Vec4(1.0f);

            for (int i = 0; i < 8; ++i)
            {
                // matrix multiply
                Vec4 w = row0 * v.SplatX();
                w = row1.MultiplyAdd(v.SplatY(), w);
                w = row2.MultiplyAdd(v.SplatZ(), w);

                // get max component from xyz in all channels
                Vec4 a = Vec4.Max(w.SplatX(), Vec4.Max(w.SplatY(), w.SplatZ()));

                // divide through and advance
                v = w * a.Reciprocal();
            }

            return(v.GetVec3());
        }
Пример #3
0
 public static Vec4 Clamp(this Vec4 value, Vec4 min, Vec4 max)
 {
     return(Vec4.Max(min, Vec4.Min(max, value)));
 }