当前位置: 首页>>代码示例>>C#>>正文


C# Matrix.TransformPoints方法代码示例

本文整理汇总了C#中Matrix.TransformPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.TransformPoints方法的具体用法?C# Matrix.TransformPoints怎么用?C# Matrix.TransformPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix的用法示例。


在下文中一共展示了Matrix.TransformPoints方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RotateAndFindNewDimensions

    private static PointF RotateAndFindNewDimensions(PointF point, float angle) {
        using (Matrix matrix = new Matrix()) {
            PointF[] points = new PointF[] {
                    new PointF(0f, 0f),
                    new PointF(0f, point.Y),
                    new PointF(point.X, 0f),
                    new PointF(point.X, point.Y)
                };

            matrix.Rotate(angle);
            matrix.TransformPoints(points);
            float minX = points[0].X;
            float maxX = minX;
            float minY = points[0].Y;
            float maxY = minY;
            for (int i = 1; i < 4; i++) {
                minX = Math.Min(minX, points[i].X);
                maxX = Math.Max(maxX, points[i].X);
                minY = Math.Min(minY, points[i].Y);
                maxY = Math.Max(maxY, points[i].Y);
            }

            return new PointF(maxX - minX, maxY - minY);
        }
    }
开发者ID:javidondeesta,项目名称:tech-talks,代码行数:25,代码来源:MultiThumbnailGenerator.cs

示例2: WorldTransform

        //	sets up a translation matrix for the sweeper according to its
        public void WorldTransform(ref List<Point> sweeper)
        {
            //create the world transformation matrix
            var transform = new Matrix();

            //scale
            transform.Scale(Scale, Scale);

            //rotate
            transform.Rotate(Rotation);

            //and translate
            transform.Translate(Position.X, Position.Y);

            //now transform the ships vertices
            transform.TransformPoints(ref sweeper);
        }
开发者ID:Oxymoron290,项目名称:CSharp-AI-Mine-Sweepers,代码行数:18,代码来源:MineSweeper.cs

示例3: GetTransformedRectangle

 private Rectangle GetTransformedRectangle(DockState dockState, Rectangle rect)
 {
     if (dockState != dockState.DockLeftAutoHide && dockState != dockState.DockRightAutoHide)
     {
         return rect;
     }
     PointF[] pts = new PointF[2]();
     // the center of the rectangle
     pts[0].X = (rect.X)+ (rect.Width)/ 2;
     pts[0].Y = (rect.Y)+ (rect.Height)/ 2;
     Rectangle rectTabStrip = GetLogicalTabStripRectangle(dockState);
     Matrix matrix = new Matrix();
     matrix.RotateAt(90, new PointF((rectTabStrip.X)+ (rectTabStrip.Height)/ 2, (rectTabStrip.Y)+ (rectTabStrip.Height)/ 2));
     matrix.TransformPoints(pts);
     return new Rectangle(System.Convert.ToInt32(pts[0].X - (rect.Height)/ 2 + 0.5F), System.Convert.ToInt32(pts[0].Y - (rect.Width)/ 2 + 0.5F), rect.Height, rect.Width);
 }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:16,代码来源:AutoHideStripFromBase.cs

示例4: GetPoints

    public Point[] GetPoints(int nPoints, Matrix m)
    {
        // Generate sequence of points on ellipse.
        Point[] points = new Point[nPoints];
        for (int i=0; i < nPoints; ++i)
        {
            double t = i* 2 * Math.PI / nPoints;
            double x = mj*Math.Cos(t);
            double y = mn*Math.Sin(t);

            double h = Math.Sqrt(x*x + y*y);
            double q = Math.Atan2(y,x);

            x = h*Math.Cos(q+Geometry.Deg2Rad(th));
            y = h*Math.Sin(q+Geometry.Deg2Rad(th));

            points[i].X = (int)Math.Round(x+cx);
            points[i].Y = (int)Math.Round(y+cy);
        }

        // Apply the transform to the points.
        m.TransformPoints(points);

        return points;
    }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:25,代码来源:Ellipse.cs

示例5: WorldTransform

        public void WorldTransform(ref List<Point> verticalBuffer, Vector vPos)
        {
            //create the world transformation matrix
            var transform = new Matrix();
	
            //scale
            transform.Scale(Properties.Settings.Default.MinScale, Properties.Settings.Default.MinScale);
	
            //translate
            transform.Translate(vPos.X, vPos.Y);

            //transform the ships vertices
            transform.TransformPoints(ref verticalBuffer);
        }
开发者ID:Oxymoron290,项目名称:CSharp-AI-Mine-Sweepers,代码行数:14,代码来源:Controller.cs

示例6: TransformPoint

 public static Point TransformPoint(Matrix m, Point p)
 {
     Point[] wrap = new Point[] { p };
     m.TransformPoints(wrap);
     return wrap[0];
 }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:6,代码来源:Geometry.cs

示例7: F

        public double F(double angle)
        {
            // Make a scratch copy of the vertices.
            Point[] verts = this.verts.Clone() as Point[];

            // Rotate them the specified amount, around the centroid.
            using (Matrix m = new Matrix())
            {
                m.RotateAt((float)angle, new PointF(center.X,center.Y));
                m.TransformPoints(verts);
            }

            // Accumulate the segments' deviation from 0/15/30/60/90.
            double sumE = 0.0;

            int n = verts.Length;
            for (int i=0; i < n; ++i)
            {
                int a=i; int b=i+1;
                if (b >= n) b = 0; // wrap

                double sidelen = Geometry.DistanceBetween(verts[a],verts[b]);

                double theta = Geometry.Rad2Deg(
                    Math.Atan2(verts[b].Y-verts[a].Y,verts[b].X-verts[a].X));

                // Quantize angle around 0/30/45/60/90/120/135/150/180.
                sumE += sidelen * Math.Min(
                    Math.Abs(Math.IEEERemainder(theta,30.0)),
                    Math.Abs(Math.IEEERemainder(theta,45.0)));
            }

            dbg.WriteLine(String.Format("Testing {0}°, error={1}", angle, sumE));
            return sumE;
        }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:35,代码来源:PolygonRegularizer.cs

示例8: ReconstructIdealizedPolygon

    private void ReconstructIdealizedPolygon()
    {
        int n = vertices.Length;
        // An extra spot for a temporary "tailpoint".
        Point[] idealvertsx = new Point[n+1];

        // First, find longest segment (to use as starting point).
        int longesti = -1;
        double longest = -1;
        for (int i=0; i < n; ++i)
        {
            if (this.idealsidelengths[i] > longest)
            { longest = this.idealsidelengths[i]; longesti = i; }
        }
        int longestj = longesti+1;
        if (longestj >= n) longestj = 0; //wrap

        // Start at vertex ahead of longest segment, and go from there.
        idealvertsx[0] = vertices[longesti];
        double theta = Math.Atan2(vertices[longestj].Y-vertices[longesti].Y,
            vertices[longestj].X-vertices[longesti].X);

        for (int i=0; i < n; ++i)
        {
            int ii = longesti+i;
            if (ii >= n) ii -= n; //wrap

            idealvertsx[i+1] = Geometry.OffsetPolar(
                idealvertsx[i],theta,idealsidelengths[ii]);

            int jj = ii+1;
            if (jj >= n) jj = 0; // wrap
            theta += Geometry.Deg2Rad(idealanglescomplement[jj]);
        }

        // Replace headpoint and tailpoint with virtual intersection.
        double tAB, tPQ;
        Point headA=idealvertsx[0],headB=idealvertsx[1],
            tailP=idealvertsx[n-1],tailQ=idealvertsx[n-0];
        SegmentCollision.HitTest(headA,headB,tailP,tailQ, out tAB, out tPQ);

        Point virtualIntersectH = Geometry.Interpolate(headA,headB,tAB);
        Point virtualIntersectT = Geometry.Interpolate(tailP,tailQ,tPQ);
        Point virtualIntersect = Geometry.Interpolate(virtualIntersectH,virtualIntersectT,0.5);

        this.idealverts = new Point[n];
        Array.Copy(idealvertsx,idealverts,n);
        idealverts[0] = virtualIntersect;

        // Recenter on original center of gravity (CG).
        Point oldcg = Geometry.EstimatePolygonCentroid(vertices);
        Point newcg = Geometry.EstimatePolygonCentroid(idealverts);
        using (Matrix m = new Matrix())
        {
            m.Translate(oldcg.X-newcg.X,oldcg.Y-newcg.Y);
            m.TransformPoints(idealverts);
        }
    }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:58,代码来源:PolygonRegularizer.cs

示例9: QuantizeSegmentOrientations

    private void QuantizeSegmentOrientations()
    {
        // Find the optimal rotation angle, to minimize segments' orientation from 0/30/45/60.
        Point center = Geometry.EstimatePolygonCentroid(idealverts);
        QsoImpl fi = new QsoImpl(idealverts,center);
        GoldenSectionDescender.F f = new GoldenSectionDescender.F(fi.F);
        GoldenSectionDescender gsd = new GoldenSectionDescender(f);

        double tolerance = 0.01;
        double optangle = gsd.FindMinimumWithin(-12.0,+12.0,tolerance);

        // Now rotate them!
        using (Matrix m = new Matrix())
        {
            m.RotateAt((float)optangle, new PointF(center.X,center.Y));
            m.TransformPoints(idealverts);
        }
    }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:18,代码来源:PolygonRegularizer.cs

示例10: Transform

    internal override void Transform(Matrix m)
    {
        UpdateGP();

        m.TransformPoints(Vertices);

        gp.Transform(m);
        displacement.Reset();

        if (rgncache != null)
        {
            rgncache.Transform(m);
            cgcache = Geometry.TransformPoint(m,cgcache);
        }
    }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:15,代码来源:MagicObjects.cs


注:本文中的Matrix.TransformPoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。