コード例 #1
0
ファイル: VectorF.cs プロジェクト: yzylovepmn/YDrawing2D
 public static VectorF Multiply(VectorF vector, MatrixF matrix)
 {
     return(matrix.Transform(vector));
 }
コード例 #2
0
ファイル: GLPanel.cs プロジェクト: yzylovepmn/YDrawing2D
 private PointF _ViewToWorld(PointF p)
 {
     p = _view.Transform(p);
     p = new PointF(p.X + _origin.X, p.Y + _origin.Y);
     return(p);
 }
コード例 #3
0
ファイル: GLPanel.cs プロジェクト: yzylovepmn/YDrawing2D
 private PointF _WorldToView(PointF p)
 {
     p = new PointF(p.X - _origin.X, p.Y - _origin.Y);
     p = _viewResverse.Transform(p);
     return(p);
 }
コード例 #4
0
ファイル: PointF.cs プロジェクト: yzylovepmn/YDrawing2D
 public static PointF Multiply(PointF point, MatrixF matrix)
 {
     return(matrix.Transform(point));
 }
コード例 #5
0
 internal PointF Transform(PointF point)
 {
     return(_matrix.Transform(point));
 }
コード例 #6
0
        internal static void TransformRect(ref RectF rect, ref MatrixF matrix)
        {
            if (rect.IsEmpty)
            {
                return;
            }

            MatrixTypes matrixType = matrix._type;

            // If the matrix is identity, don't worry.
            if (matrixType == MatrixTypes.TRANSFORM_IS_IDENTITY)
            {
                return;
            }

            // Scaling
            if (0 != (matrixType & MatrixTypes.TRANSFORM_IS_SCALING))
            {
                rect._x      *= matrix._m11;
                rect._y      *= matrix._m22;
                rect._width  *= matrix._m11;
                rect._height *= matrix._m22;

                // Ensure the width is always positive.  For example, if there was a reflection about the
                // y axis followed by a translation into the visual area, the width could be negative.
                if (rect._width < 0.0)
                {
                    rect._x    += rect._width;
                    rect._width = -rect._width;
                }

                // Ensure the height is always positive.  For example, if there was a reflection about the
                // x axis followed by a translation into the visual area, the height could be negative.
                if (rect._height < 0.0F)
                {
                    rect._y     += rect._height;
                    rect._height = -rect._height;
                }
            }

            // Translation
            if (0 != (matrixType & MatrixTypes.TRANSFORM_IS_TRANSLATION))
            {
                // X
                rect._x += matrix._offsetX;

                // Y
                rect._y += matrix._offsetY;
            }

            if (matrixType == MatrixTypes.TRANSFORM_IS_UNKNOWN)
            {
                // Al Bunny implementation.
                PointF point0 = matrix.Transform(rect.TopLeft);
                PointF point1 = matrix.Transform(rect.TopRight);
                PointF point2 = matrix.Transform(rect.BottomRight);
                PointF point3 = matrix.Transform(rect.BottomLeft);

                // Width and height is always positive here.
                rect._x = Math.Min(Math.Min(point0.X, point1.X), Math.Min(point2.X, point3.X));
                rect._y = Math.Min(Math.Min(point0.Y, point1.Y), Math.Min(point2.Y, point3.Y));

                rect._width  = Math.Max(Math.Max(point0.X, point1.X), Math.Max(point2.X, point3.X)) - rect._x;
                rect._height = Math.Max(Math.Max(point0.Y, point1.Y), Math.Max(point2.Y, point3.Y)) - rect._y;
            }
        }