Random Rectangle Set Generator

Generate bounded rectangles with dimension, area, and perimeter metadata.

Description

Generate rectangle dimensions with calculated area and perimeter within a chosen dimension bound.

A rectangle has perpendicular adjacent sides; width and height determine its area and perimeter. Using a shared length unit makes area a squared-unit quantity and perimeter a length.1

This generator samples width and height independently and returns result.rectangles entries with width, height, area, and perimeter. The bound controls each dimension, while location, orientation, and vertices are left to the caller.

When to use Random Rectangle Set Generator

Use it for rectangle measurement exercises or dimension-and-answer fixtures for a drawing application.

How to use Random Rectangle Set Generator and understand its results

  1. Enter integer shapeCount from 1 through 256 and positive finite maximumDimension no greater than 1e100.
  2. Run and read result.rectangles, keeping width and height in the same chosen length unit.
  3. Use area and perimeter as answer values or calculated metadata. Add placement or rendering separately, and round measurements only for display.
width = M × (0.1 + 0.9 × r1); height = M × (0.1 + 0.9 × r2)

Each rectangle consumes two independent draws. Both dimensions start at 10% of the maximum and approach the maximum.

area = width × height; perimeter = 2 × (width + height)

The rectangle measurement calculators supply these values; the output does not swap the sampled dimensions into size order.

json
{
  "input": {
    "shapeCount": 3,
    "maximumDimension": 10
  },
  "randomDraw": 0.25,
  "output": {
    "result": {
      "rectangles": [
        {
          "area": 10.5625,
          "height": 3.25,
          "perimeter": 13,
          "width": 3.25
        },
        {
          "area": 10.5625,
          "height": 3.25,
          "perimeter": 13,
          "width": 3.25
        },
        {
          "area": 10.5625,
          "height": 3.25,
          "perimeter": 13,
          "width": 3.25
        }
      ]
    }
  }
}

Width can be smaller than, equal to, or larger than height. Shape count one is valid. Nonpositive bounds, counts outside 1–256, and invalid draws fail; very small positive bounds can underflow area calculations.

Limitations and assumptions

The default source is Math.random; no seed input or cryptographic entropy guarantee is provided. Repeated runs may select the same result, and the distribution depends on the random source.

There are no positions, rotations, vertex coordinates, diagrams, overlap constraints, or requested aspect ratios. Independent dimension sampling is not uniform over rectangle areas. Repeated rectangles are permitted.

Alternative or Complementary methods

Use individual rectangle calculators to check specific dimensions. A regular-polygon generator chooses a different shape family and returns rotation metadata.

References

  1. Contemporary Mathematics: Area — OpenStax, Rice University

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies