Esempio n. 1
0
 private void RenderBody(Graphics gfx, Body2 body)
 {
     if (body.Shape is Circle)
     {
         Circle c         = body.Shape as Circle;
         Vec2   beginning = body.Position.Sub(c.Radius);
         gfx.DrawEllipse(Pens.Red, new Rectangle((int)beginning.X, (int)beginning.Y, (int)c.Radius * 2, (int)c.Radius * 2));
     }
     if (body.Shape is Poly2)
     {
         Poly2 p = body.Shape as Poly2;
         for (int i = 0; i < p.Vertices.Count; ++i)
         {
             Math.Matrix.Mat2 rot = Math.Matrix.Mat2.Rotation(body.Rotation);
             int  j   = i + 1 < p.Vertices.Count ? i + 1 : 0;
             Vec2 v1  = body.Position.Add(rot.Mul(p.Vertices[i]));
             Vec2 v2  = body.Position.Add(rot.Mul(p.Vertices[j]));
             Vec2 mid = v1.Add(v2).Div(2);
             Vec2 dir = mid.Add(rot.Mul(p.Normals[i]).Mul(10));
             gfx.DrawLine(Pens.Red, new Point((int)v1.X, (int)v1.Y), new Point((int)v2.X, (int)v2.Y));
             gfx.DrawLine(Pens.Green, new Point((int)mid.X, (int)mid.Y), new Point((int)dir.X, (int)dir.Y));
             gfx.FillEllipse(Brushes.Blue, new Rectangle((int)v1.X - 1, (int)v1.Y - 2, 4, 4));
             gfx.FillEllipse(Brushes.Blue, new Rectangle((int)v2.X - 1, (int)v2.Y - 2, 4, 4));
         }
     }
 }
Esempio n. 2
0
 public Mat2 MulLeft(Mat2 m)
 {
     return(ToMat2(m.Mul(this)));
 }
Esempio n. 3
0
 public Mat2 Mul(Mat2 m)
 {
     return(ToMat2(base.Mul(m)));
 }