Exemple #1
0
        public static void DrawShape(Shape shape, Matrix transform, Color color, SpriteBatch spriteBatch)
        {
            List<Edge> edges = shape.GetEdges();

            foreach (Edge e in edges)
            {
                Vector2 transformedV1 = Vector2.Transform(e.V1, transform);
                Vector2 transformedV2 = Vector2.Transform(e.V2, transform);

                LineBatch.DrawLine(
                    spriteBatch,
                    color,
                    transformedV1,
                    transformedV2);
            }
        }
        public static void ProjectShapeToAxis(Vector2 axis, Shape shape, ref float min, ref float max)
        {
            List<Vector2> vertices = shape.GetVertices();
            float proj = LinearFunctions.GetProjection(axis, vertices[0]);

            min = max = proj;

            for (int i = 1; i < vertices.Count; i++)
            {
                proj = LinearFunctions.GetProjection(axis, vertices[i]);

                if (proj < min)
                {
                    min = proj;
                }
                else if (proj > max)
                {
                    max = proj;
                }
            }
        }
 public static Shape GetTransformedShape(Shape shape, Matrix transform)
 {
     Shape newShape = new Shape(LinearFunctions.GetTransformedVertices(shape.GetVertices(), transform));
     return newShape;
 }