static void Main(string[] args)
        {
            Size size1   = new Size(640, 480);
            Size size2   = new Size(480, 640);                                  // compiles, but wrong
            Size size3   = new Size(height: 480, width: 640);
            var  height1 = size1.Height;
            var  width1  = size1.Width;

            Width2  aWidth2  = new Width2(640);
            Height2 aHeight2 = new Height2(480);
            Size2   size21   = new Size2(aWidth2, aHeight2);
            Size2   size22   = new Size2(aHeight2, aWidth2);                      // compiler reports error
            Size2   size23   = new Size2(height: aHeight2, width: aWidth2);
            var     height2  = size21.Height.Value;
            var     width2   = size21.Width.Value;

            Size3 size31  = new Size3(new Width3(640), new Height3(480));
            Size3 size32  = new Size3((Width3)640, (Height3)480);
            Size3 size33  = new Size3((Height3)480, (Width3)640);               // compiler reports error
            Size3 size34  = new Size3(height: (Height3)480, width: (Width3)640);
            int   height3 = size32.Height.Value;
            int   width3  = size32.Width.Value;

            Size4 size41  = new Size4(new Width4(640), new Height4(640));
            int   width4  = size41.Width;
            int   height4 = size41.Height;

            var  width  = new Width4(640);
            var  height = new Height4(480);
            Size size4  = new Size(width, height);
            Size size5  = new Size(height, width);                              // compiles, but wrong
            Size size6  = new Size(height: height, width: width);
        }
예제 #2
0
        public static float FastInverseSquareRoot(float number)
        {
            float x2 = number * 0.5f;

            int i = 0x5f375a86 - ((new Size4(number).asInt) >> 1); //Evil bit level hacking ;)

            number = new Size4(i).asFloat;                         //Abusing StructLayout to "safely" reinterpret float-int

            return(number * (1.5f - (x2 * number * number)));
        }