pyoptools.raytrace.shape.rectangular module

Module that defines the Rectangular class

class pyoptools.raytrace.shape.rectangular.Rectangular

Bases: Shape

Class defining a rectangular shape.

The Rectangular class represents a rectangular aperture or surface shape, defined by its size. It inherits from the Shape class and implements methods specific to rectangular shapes.

Parameters:
  • size (tuple of float, optional) – A tuple (width, height) that defines the size of the rectangle. Defaults to (1.0, 1.0).

  • samples (tuple of int, optional) – A tuple (nx, ny) that determines the number of samples used to discretize the rectangle along its width and height, respectively. Defaults to (30, 30).

  • offset (tuple of float, optional) – A tuple (x_offset, y_offset) that specifies the offset of the rectangle from the origin. Defaults to (0.0, 0.0).

size

A tuple (width, height) representing the dimensions of the rectangle.

Type:

tuple of float

samples

A tuple (nx, ny) representing the number of samples along the width and height of the rectangle.

Type:

tuple of int

offset

A tuple (x_offset, y_offset) representing the offset of the rectangle from the origin.

Type:

tuple of float

limits()

Return the minimum and maximum limits of the rectangular aperture.

This method returns the minimum and maximum X and Y coordinates that define the bounding box of the rectangular aperture. These limits are calculated based on the size of the rectangle and its offset from the origin.

Returns:

A tuple (xmin, xmax, ymin, ymax) where: - xmin is the minimum X-coordinate, calculated as -dx/2 + ox. - xmax is the maximum X-coordinate, calculated as dx/2 + ox. - ymin is the minimum Y-coordinate, calculated as -dy/2 + oy. - ymax is the maximum Y-coordinate, calculated as dy/2 + oy.

Return type:

tuple of float

Notes

  • dx and dy represent the width and height of the rectangle,

respectively. - ox and oy represent the X and Y offsets of the rectangle from the origin. - These limits define a rectangular bounding box that fully contains the aperture.

offset
pointlist()

Generate a list of points that adequately sample the rectangular shape.

This method returns two lists, X and Y, representing the X and Y coordinates of points that sample the rectangular shape. The sampling resolution is determined by the number of divisions along the width and height of the rectangle, specified by the samples attribute.

The method explicitly calculates the grid points, taking into account the size of the rectangle and its offset from the origin.

Returns:

A tuple (X, Y) where X is a list of X coordinates and Y is a list of Y coordinates for the sampled points on the rectangular shape.

Return type:

tuple of lists

Notes

  • The samples attribute defines the resolution of the sampling:
    • nx (number of samples along the width) determines the number of

    points along the X-axis. - ny (number of samples along the height) determines the number of points along the Y-axis.

  • The points are calculated such that the grid spans from -dx/2 + ox

to dx/2 + ox in the X direction and from -dy/2 + oy to dy/2 + oy in the Y direction, where dx and dy are the width and height of the rectangle, and ox and oy are the offsets.

samples
size