Class SolidPolygonRectangularBox

Direct Known Subclasses:
SolidPolygonCube

public class SolidPolygonRectangularBox extends AbstractCompositeShape
A solid (filled) rectangular box composed of 12 triangular polygons (2 per face, covering all 6 faces). Each face is rendered as a pair of SolidPolygon triangles with the same color.

The box can be constructed either from a center point and a uniform size (producing a cube), or from two diagonally opposite corner points (producing an arbitrary axis-aligned rectangular box).

The vertices are labeled p1 through p8, representing the eight corners of the box. The triangles are arranged to cover the bottom, top, front, back, left, and right faces.

Usage example:


 // From center and size:
 SolidPolygonRectangularBox box1 = new SolidPolygonRectangularBox(
         new Point3D(0, 0, 200), 100, Color.RED);

 // From two corner points:
 SolidPolygonRectangularBox box2 = new SolidPolygonRectangularBox(
         new Point3D(-50, -25, 100), new Point3D(50, 25, 200), Color.BLUE);

 shapeCollection.addShape(box1);
 
See Also:
  • Constructor Details

    • SolidPolygonRectangularBox

      public SolidPolygonRectangularBox(Point3D p1, Point3D p7, Color color)
      Constructs a solid rectangular box between two diagonally opposite corner points in 3D space. The eight vertices of the box are derived from the coordinate components of p1 and p7. All six faces are tessellated into two triangles each, for a total of 12 solid polygons.
      Parameters:
      p1 - the first corner point (minimum coordinates by convention)
      p7 - the diagonally opposite corner point (maximum coordinates)
      color - the fill color applied to all 12 triangular polygons