InitIdentity() public method

public InitIdentity ( ) : void
return void
        public Matrix Fit(Gdk.Rectangle viewport)
        {
            Matrix m = new Matrix ();
            m.InitIdentity ();

            double scale = Math.Min (viewport.Width / (double) Bounds.Width,
                         viewport.Height / (double) Bounds.Height);

            double x_offset = (viewport.Width  - Bounds.Width * scale) / 2.0;
            double y_offset = (viewport.Height  - Bounds.Height * scale) / 2.0;

            m.Translate (x_offset, y_offset);
            m.Scale (scale, scale);
            return m;
        }
        //
        // this functions calculates the transformation needed to center and completely fill the
        // viewport with the Surface at the given tilt
        //
        public Matrix Fill(Gdk.Rectangle viewport, double tilt)
        {
            if (tilt == 0.0)
                return Fill (viewport);

            Matrix m = new Matrix ();
            m.InitIdentity ();

            double len;
            double orig_len;
            if (Bounds.Width > Bounds.Height) {
                len = viewport.Height;
                orig_len = Bounds.Height;
            } else {
                len = viewport.Width;
                orig_len = Bounds.Width;
            }

            double a = Math.Sqrt (viewport.Width * viewport.Width + viewport.Height * viewport.Height);
            double alpha = Math.Acos (len / a);
            double theta = alpha - Math.Abs (tilt);

            double slen = a * Math.Cos (theta);

            double scale = slen / orig_len;

            double x_offset = (viewport.Width  - Bounds.Width * scale) / 2.0;
            double y_offset = (viewport.Height  - Bounds.Height * scale) / 2.0;

            m.Translate (x_offset, y_offset);
            m.Scale (scale, scale);
            m.Invert ();
            m.Translate (viewport.Width * 0.5, viewport.Height * 0.5);
            m.Rotate (tilt);
            m.Translate (viewport.Width * -0.5, viewport.Height * -0.5);
            m.Invert ();
            return m;
        }