pyoptools.raytrace.shape.shape module

class pyoptools.raytrace.shape.shape.Shape

Bases: Picklable

Abstract superclass for all optical surface shapes.

Shape is an abstract superclass that defines the interface for different surface shapes (e.g., circular, rectangular). This class provides an API that all subclasses must implement to define specific shapes and behaviors.

Subclasses are required to implement methods for checking whether a point is inside the shape, defining the shape’s limits, and generating lists of points that sample the shape adequately.

topo

A function Z(x, y) that describes the topography of the surface. This attribute should be initialized as needed.

Type:

callable

hit(point)

Determine if a point is within the surface aperture.

This method checks whether a given point (x, y, z) lies inside the surface aperture. It returns True if the point is within the aperture and False otherwise.

The method relies on the hit_cy method, which must be implemented in all subclasses of Shape.

Parameters:

point (tuple of float) – A tuple representing the coordinates (x, y, z) of the point to check.

Returns:

True if the point is within the surface aperture, False otherwise.

Return type:

bool

limits()

Return the minimum and maximum limits for the aperture.

This method should be overridden in each subclass to return the specific limits of the shape.

Returns:

The minimum and maximum limits (xi, xf, yi, yf) of the aperture.

Return type:

tuple of float

pointlist()

Generate a list of points that adequately sample the shape.

This method should return a tuple (X, Y) where X contains the X coordinates of the points and Y contains the Y coordinates. The points must be sampled adequately to be used as vertices for generating the triangles required to plot the surface defined by (X, Y, self.topo(X, Y)).

The method must be implemented in each subclass to ensure that the sampling is appropriate for the specific shape.

Returns:

A tuple (X, Y) where X is a list of X coordinates and Y is a list of Y coordinates, sampled adequately for surface plotting.

Return type:

tuple of lists

Raises:

NotImplementedError – If this method is not implemented in a subclass, an error is raised indicating that the method must be overloaded.