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


C# Matrix.RotateAt方法代码示例

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


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

示例1: RotationMatrix

 // Create rotation matrix.
 public static Matrix RotationMatrix(float angle, PointF location)
 {
     #if false
     Matrix m = Matrix.Identity;
     m.RotateAtPrepend(angle, location.X, location.Y);
     return m;
     #else
     Matrix m = new Matrix();
     m.RotateAt(angle, location);
     return m;
     #endif
 }
开发者ID:jonc,项目名称:carto,代码行数:13,代码来源:GraphicsTarget.cs

示例2: 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

示例3: RandomWarp

    public GraphicsPath RandomWarp(GraphicsPath path)
    {
        // Add line //
        int PsCount = 10;
        PointF[] curvePs = new PointF[PsCount * 2];
        for (int u = 0; u < PsCount; u++)
        {
            curvePs[u].X = u * (Width / PsCount);
            curvePs[u].Y = Height / 2;
        }
        for (int u = PsCount; u < (PsCount * 2); u++)
        {
            curvePs[u].X = (u - PsCount) * (Width / PsCount);
            curvePs[u].Y = Height / 2 + 2;
        }

        double eps = Height * 0.05;

        double amp = rnd.NextDouble() * (double)(Height / 3);
        double size = rnd.NextDouble() * (double)(Width / 4) + Width / 8;

        double offset = (double)(Height / 3);

        PointF[] pn = new PointF[path.PointCount];
        byte[] pt = new byte[path.PointCount];

        GraphicsPath np2 = new GraphicsPath();

        GraphicsPathIterator iter = new GraphicsPathIterator(path);
        for (int i = 0; i < iter.SubpathCount; i++)
        {
            GraphicsPath sp = new GraphicsPath();
            bool closed;
            iter.NextSubpath(sp, out closed);

            Matrix m = new Matrix();
            m.RotateAt(Convert.ToSingle(rnd.NextDouble() * 30 - 15), sp.PathPoints[0]);

            m.Translate(-1 * i, 0);//uncomment

            sp.Transform(m);

            np2.AddPath(sp, true);
        }

        for (int i = 0; i < np2.PointCount; i++)
        {
            //pn[i] = Noise( path.PathPoints[i] , eps);
            pn[i] = Wave(np2.PathPoints[i], amp, size);
            pt[i] = np2.PathTypes[i];
        }

        GraphicsPath newpath = new GraphicsPath(pn, pt);

        return newpath;
    }
开发者ID:,项目名称:,代码行数:56,代码来源:

示例4: updateEntity

    public override void updateEntity()
    {
        this.setVelocity();

        Matrix moveMatrix = new Matrix();
        double radians = ConversionTools.degreesToRadians(this.getEntityHeading());
        double xMovement = Math.Cos(radians) * this.velocity;
        double yMovement = Math.Sin(radians) * this.velocity;

        this.setEntityCenterX(xMovement += this.getEntityCenterX());
        this.setEntityCenterY(yMovement += this.getEntityCenterY());
        double newHeading = this.getEntityHeading() + this.rotation;

        moveMatrix.Translate(xMovement, yMovement);
        moveMatrix.RotateAt(newHeading, this.getEntityCenterX(), this.getEntityCenterY());
        this.setEntityHeading(newHeading);
        this.entityShape.RenderTransform = new MatrixTransform(moveMatrix);

        this.handleWallCollisions();
        this.updateMyBullets();
    }
开发者ID:Beansy,项目名称:Asteroids,代码行数:21,代码来源:PlayerShip.cs

示例5: DrawTabStrip

 private void DrawTabStrip(Graphics g, DockState dockState)
 {
     Rectangle rectTabStrip = GetLogicalTabStripRectangle(dockState);
     if (rectTabStrip.IsEmpty)
     {
         return;
     }
     Matrix matrixIdentity = g.Transform;
     if (dockState == dockState.DockLeftAutoHide || dockState == dockState.DockRightAutoHide)
     {
         Matrix matrixRotated = new Matrix();
         matrixRotated.RotateAt(90, new PointF((rectTabStrip.X)+ (rectTabStrip.Height)/ 2, (rectTabStrip.Y)+ (rectTabStrip.Height)/ 2));
         g.Transform = matrixRotated;
     }
     foreach (AutoHidePane pane in GetPanes(dockState))
     {
         foreach (AutoHideTabFromBase tab in pane.Tabs)
         {
             DrawTab(g, tab);
         }
     }
     g.Transform = matrixIdentity;
 }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:23,代码来源:AutoHideStripFromBase.cs

示例6: updateEntity

    public override void updateEntity()
    {
        Matrix moveMatrix = new Matrix();

        double radians = ConversionTools.degreesToRadians(this.getEntityHeading());
        double xMovement = Math.Cos(radians) * this.speed;
        double yMovement = Math.Sin(radians) * this.speed;

        this.setEntityCenterX(xMovement += this.getEntityCenterX());
        this.setEntityCenterY(yMovement += this.getEntityCenterY());
        moveMatrix.Translate(xMovement, yMovement);
        moveMatrix.RotateAt(this.rotation, this.getEntityCenterX(), this.getEntityCenterY());
        this.entityShape.RenderTransform = new MatrixTransform(moveMatrix);

        this.rotation += 5;
        this.handleWallCollisions();
        this.checkPlayerCollision();
        this.checkBulletCollision();
    }
开发者ID:Beansy,项目名称:Asteroids,代码行数:19,代码来源:Asteroid.cs

示例7: Tick


//.........这里部分代码省略.........
        // Look for collisions, apply impulses.
        collisions.Clear();
        foreach (RigidBodyBase body1 in doc.Bodies)
        foreach (RigidBodyBase body2 in doc.Bodies)
        {
            if (Object.ReferenceEquals(body1,body2)) continue;

            if (body1.anchored && body2.anchored) continue;

            Point contactPoint;
            PointF normal;
            if (!FindIntersection(body1, body2, out contactPoint, out normal)) continue;

            using (Graphics g = wnd.CreateGraphics())
            using (Region contactrgn = RigidBodyBase.GetOverlap(body1,body2))
            {
                if (contactrgn.IsEmpty(g)) continue;

                // We've got a hit; but make sure it's waxing not waning.
                int dx1=0,dy1=0,dx2=0,dy2=0; float da1=0f,da2=0f;

                dx1 = MathEx.Round(dt * body1.Vx);
                dy1 = MathEx.Round(dt * body1.Vy);
                da1 = (float)Geometry.Rad2Deg(dt * body1.Va);
                dx2 = MathEx.Round(dt * body2.Vx);
                dy2 = MathEx.Round(dt * body2.Vy);
                da2 = (float)Geometry.Rad2Deg(dt * body2.Va);

                using (Matrix m1 = new Matrix())
                using (Matrix m2 = new Matrix())
                using (Region rgn = new Region())
                {
                    m1.Translate(dx1,dy1);
                    m1.RotateAt(da1,body1.CG);
                    m2.Translate(dx2,dy2);
                    m2.RotateAt(da2,body2.CG);

                    Region contactrgn1 = body1.rgncache.Clone();
                    Region contactrgn2 = body2.rgncache.Clone();

                    contactrgn1.Transform(m1);
                    contactrgn2.Transform(m2);

                    rgn.Intersect(contactrgn1);
                    rgn.Intersect(contactrgn2);

                    float newarea = Geometry.CalculateArea(rgn);
                    float oldarea = Geometry.CalculateArea(contactrgn);

                    if (newarea < oldarea)
                        continue;
                }

                // Calculate contact point, and relative velocities.

                // Make a 1000 unit normal so that we can use ints.
                Vector collNormal = new Vector(MathEx.Round(normal.X * 1000),
                    MathEx.Round(normal.Y * 1000));
                double collNormalLength = collNormal.Length;
                if (collNormalLength == 0)
                    continue;

                // Find the relative velocity at the collision point.
                Vector rvBodies = new Vector(MathEx.Round(body1.Vx - body2.Vx),
                    MathEx.Round(body1.Vy - body2.Vy));
                // Add in the velocity due to rotation of the bodies.
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:67,代码来源:AnimationEngine.cs

示例8: 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

示例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: Test

    /// <summary>
    /// Some test code to check that there are no typing errors in the formulars.
    /// </summary>
    public static void Test()
    {
      XMatrix xm1 = new XMatrix(23, -35, 837, 332, -3, 12);
      Matrix  m1 = new Matrix(23, -35, 837, 332, -3, 12);
      DumpMatrix(xm1, m1);
      XMatrix xm2 = new XMatrix(12, 235, 245, 42, 33, -56);
      Matrix  m2 = xm2.ToMatrix();
      DumpMatrix(xm2, m2);

//      xm1.Multiply(xm2, XMatrixOrder.Prepend);
//      m1.Multiply(m2, MatrixOrder.Append);
      xm1.Multiply(xm2, XMatrixOrder.Append);
      m1.Multiply(m2, MatrixOrder.Append);
      DumpMatrix(xm1, m1);

      xm1.Translate(-243, 342, XMatrixOrder.Append);
      m1.Translate(-243, 342, MatrixOrder.Append);
      DumpMatrix(xm1, m1);

      xm1.Scale(-5.66, 7.87);
      m1.Scale(-5.66f, 7.87f);
//      xm1.Scale(-5.66, 7.87, XMatrixOrder.Prepend);
//      m1.Scale(-5.66f, 7.87f, MatrixOrder.Prepend);
      DumpMatrix(xm1, m1);


      xm1.Rotate(135, XMatrixOrder.Append);
      m1.Rotate(135, MatrixOrder.Append);
      //      xm1.Scale(-5.66, 7.87, XMatrixOrder.Prepend);
      //      m1.Scale(-5.66f, 7.87f, MatrixOrder.Prepend);
      DumpMatrix(xm1, m1);

      xm1.RotateAt(177, new XPoint(-3456, 654), XMatrixOrder.Append);
      m1.RotateAt(177, new PointF(-3456, 654), MatrixOrder.Append);
      DumpMatrix(xm1, m1);

      xm1.Shear(0.76, -0.87, XMatrixOrder.Prepend);
      m1.Shear(0.76f, -0.87f, MatrixOrder.Prepend);
      DumpMatrix(xm1, m1);

      xm1 = new XMatrix(23, -35, 837, 332, -3, 12);
      m1 = new Matrix(23, -35, 837, 332, -3, 12);

      XPoint[] xpoints = new XPoint[3]{new XPoint(23, 10), new XPoint(-27, 120), new XPoint(-87, -55)};
      PointF[] points = new PointF[3]{new PointF(23, 10), new PointF(-27, 120), new PointF(-87, -55)};

      xm1.TransformPoints(xpoints);
      m1.TransformPoints(points);

      xm1.Invert();
      m1.Invert();
      DumpMatrix(xm1, m1);

    }
开发者ID:BackupTheBerlios,项目名称:zp7-svn,代码行数:57,代码来源:XMatrix.cs

示例11: Move

    internal override void Move(int dx, int dy, float da)
    {
        UpdateGP();

        using (Matrix m = new Matrix())
        {
            // Rotate the whole force vector with body object.
            PointF bodycg = new PointF(Body.Object.CG.X,Body.Object.CG.Y);

            m.Translate(dx,dy);
            m.RotateAt(da, bodycg);

            gp.Transform(m);

            // Adjust so that you are always the correct distance
            // from the center of gravity.
            Vector attachVector = Vector.FromPoint(Body.attachloc);
            Point currentAttachPt =
                new Point(MathEx.Round(gp.PathPoints[1].X), MathEx.Round(gp.PathPoints[1].Y));
            Vector currentVector = Vector.FromPoints(Body.Object.CG, currentAttachPt);
            double currentLength = currentVector.Length;
            if (currentLength > 0)
            {
                Vector deltaVector = currentVector * (1 - attachVector.Length / currentLength);
                // Adjust by this delta vector.
                m.Reset();
                m.Translate(-(int)deltaVector.DX, -(int)deltaVector.DY);
                gp.Transform(m);
            }

        }
    }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:32,代码来源:MagicObjects.cs

示例12: MoveNoStore

    internal override void MoveNoStore(int dx, int dy, float da)
    {
        UpdateGP();

        using (Matrix m = new Matrix())
        {
            m.Translate(dx,dy);
            m.RotateAt(da, new PointF(CG.X,CG.Y));

            gp.Transform(m);
            displacement.Multiply(m,MatrixOrder.Append);

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


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