How to use the raytracing.graphics.MatrixGraphic function in raytracing

To help you get started, we’ve selected a few raytracing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DCC-Lab / RayTracing / raytracing / graphics.py View on Github external
def __init__(self, matrix, x=0.0, fixedWidth=False):
        self.matrix = matrix
        super(MatrixGraphic, self).__init__(x=x, fixedWidth=fixedWidth, label=self.matrix.label)
github DCC-Lab / RayTracing / raytracing / graphics.py View on Github external
if self.matrix.L != 0:
            self.points.extend(self.verticesPoints)
        self.points.extend(self.pointsOfInterest)

        self.addPrincipalPlanes()

        from .figure import MplFigure
        from .imagingpath import ImagingPath
        path = ImagingPath(elements=[self.matrix])
        figure = MplFigure(path)
        figure.graphics = [self]
        figure.create(title="Element properties")
        figure.display2D()


class LensGraphic(MatrixGraphic):
    def __init__(self, matrix, x=0.0, fixedWidth=False, minSize=0):
        if matrix.apertureDiameter == float('+Inf') and minSize > matrix._physicalHalfHeight:
            matrix._physicalHalfHeight = minSize

        super(LensGraphic, self).__init__(matrix, x=x, fixedWidth=fixedWidth)

    @property
    def mainComponents(self):
        return [DoubleThinArrow(self.matrix.displayHalfHeight()*2)]


class ApertureGraphic(MatrixGraphic):
    def __init__(self, matrix, x=0.0):
        super().__init__(matrix, x=x)

    @property
github DCC-Lab / RayTracing / raytracing / graphics.py View on Github external
self.corners = [components[0].corners[0], components[-1].corners[1]]
        return components

    @property
    def apertureComponents(self):
        halfHeight = self.matrix.displayHalfHeight()

        if len(self.surfaces) == 1:
            return []

        outerWidth = self.corners[1] - self.corners[0]
        return [ApertureBars(y=halfHeight, x=self.corners[0], width=outerWidth)]


class MatrixGroupGraphic(MatrixGraphic):
    def __init__(self, matrixGroup, x=0.0):
        self.matrixGroup = matrixGroup
        super().__init__(matrixGroup, x=x)

    @property
    def L(self):
        L = 0
        for element in self.matrixGroup.elements:
            L += element.L
        return L

    @property
    def components(self):
        if self._components is None:
            self._components = self.mainComponents
        return self._components
github DCC-Lab / RayTracing / raytracing / graphics.py View on Github external
def __new__(cls, element, x=0.0, minSize=0) -> Union[MatrixGraphic, None, list]:
        instance = type(element).__name__
        if type(element) is Objective or issubclass(type(element), Objective):
            return ObjectiveGraphic(element, x=x)
        if instance is 'Lens':
            return LensGraphic(element, x=x, minSize=minSize)
        if instance is 'Space':
            return None
        if instance is 'Aperture':
            return ApertureGraphic(element, x=x)
        if element.surfaces:
            return SurfacesGraphic(element, x=x)
        if issubclass(type(element), MatrixGroup):
            return MatrixGroupGraphic(element, x=x).standAloneGraphics
        else:
            return MatrixGraphic(element, x=x)
github DCC-Lab / RayTracing / raytracing / graphics.py View on Github external
    @property
    def mainComponents(self):
        return [DoubleThinArrow(self.matrix.displayHalfHeight()*2)]


class ApertureGraphic(MatrixGraphic):
    def __init__(self, matrix, x=0.0):
        super().__init__(matrix, x=x)

    @property
    def mainComponents(self):
        return []


class SurfacesGraphic(MatrixGraphic):
    def __init__(self, matrix, x=0.0):
        self.surfaces = matrix.surfaces
        self.corners = None

        super(SurfacesGraphic, self).__init__(matrix, x=x, fixedWidth=True)

    @property
    def mainComponents(self):
        halfHeight = self.matrix.displayHalfHeight()

        if len(self.surfaces) == 1:
            return [Surface(self.surfaces[0], halfHeight)]

        z = 0
        components = []
        for i, surfaceA in enumerate(self.surfaces[:-1]):
github DCC-Lab / RayTracing / raytracing / graphics.py View on Github external
figure.display2D()


class LensGraphic(MatrixGraphic):
    def __init__(self, matrix, x=0.0, fixedWidth=False, minSize=0):
        if matrix.apertureDiameter == float('+Inf') and minSize > matrix._physicalHalfHeight:
            matrix._physicalHalfHeight = minSize

        super(LensGraphic, self).__init__(matrix, x=x, fixedWidth=fixedWidth)

    @property
    def mainComponents(self):
        return [DoubleThinArrow(self.matrix.displayHalfHeight()*2)]


class ApertureGraphic(MatrixGraphic):
    def __init__(self, matrix, x=0.0):
        super().__init__(matrix, x=x)

    @property
    def mainComponents(self):
        return []


class SurfacesGraphic(MatrixGraphic):
    def __init__(self, matrix, x=0.0):
        self.surfaces = matrix.surfaces
        self.corners = None

        super(SurfacesGraphic, self).__init__(matrix, x=x, fixedWidth=True)

    @property

raytracing

Simple optical ray tracing library to validate the design of an optical system (lenses positions and sizes, focal lengths, aperture and field stops). Support for Monte Carlo raytracing to estimate transmission efficiency and powers, limited but functional Zemax file loader for lenses, several material dispersion curves included for chromatic aberrations all coming from http://refractiveindex.info

MIT
Latest version published 6 months ago

Package Health Score

58 / 100
Full package analysis