Source Academy Modules
    Preparing search index...

    Function bounding_box

    • Returns a function of type (string, string) → number, for getting the specified Shape's bounding box coordinates.

      Its first parameter must be "x", "y", or "z", indicating the coordinate axis.

      Its second parameter must be "min" or "max", indicating the minimum or maximum bounding box coordinate respectively.

      For example, if a sphere of radius 0.5 is centred at (0.5, 0.5, 0.5), its minimum bounding coordinates will be (0, 0, 0), and its maximum bounding coordinates will be (1, 1, 1).

      // Sample usage
      const getter_function = bounding_box(sphere(silver));
      display(getter_function("y", "max")); // Displays 1, the maximum y coordinate

      Parameters

      • shape: Shape

        Shape to measure

      Returns (axis: string, minMax: string) => number

      bounding box getter function