public class Grid2D extends AbstractCompositeShape
A 2D grid of line segments lying in the XY plane (Z = 0 in local space). The grid is divided into configurable numbers of cells along the X and Y axes, producing a regular rectangular mesh of lines.

This shape is useful for rendering floors, walls, reference planes, or any flat surface that needs a grid overlay. The grid is positioned and oriented in world space using a Transform.

Usage example:


 Transform transform = new Transform(new Point3D(0, 100, 0));
 Rectangle rect = new Rectangle(new Point2D(-500, -500), new Point2D(500, 500));
 LineAppearance appearance = new LineAppearance(1, Color.GRAY);
 Grid2D grid = new Grid2D(transform, rect, 10, 10, appearance);
 shapeCollection.addShape(grid);
 
See Also:
  • Constructor Details

    • Grid2D

      public Grid2D(Transform transform, Rectangle rectangle, int xDivisionCount, int yDivisionCount, LineAppearance appearance)
      Constructs a 2D grid in the XY plane with the specified dimensions and number of divisions.
      Parameters:
      transform - the transform defining the grid's position and orientation in world space
      rectangle - the rectangular dimensions of the grid in local XY space
      xDivisionCount - the number of divisions (cells) along the X axis; produces xDivisionCount + 1 vertical lines
      yDivisionCount - the number of divisions (cells) along the Y axis; produces yDivisionCount + 1 horizontal lines
      appearance - the line appearance (color, width) used for all grid lines