How to use the raytracing.abcd.Space 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 / abcd.py View on Github external
def drawBeamTrace(self, axes, beam):
        """ Draw beam trace corresponding to input beam 
        Because the laser beam diffracts through space, we cannot
        simply propagate the beam over large distances and trace it
        (as opposed to rays, where we can). We must split Space() 
        elements into sub elements to watch the beam size expand.
        
        We arbitrarily split Space() elements into 100 sub elements
        before plotting.
        """

        highResolution = ImagingPath()
        for element in self.elements:
            if isinstance(element, Space):
                for i in range(100):
                    highResolution.append(Space(d=element.L/100, 
                                                n=element.frontIndex))
            else:
                highResolution.append(element)


        beamTrace = highResolution.trace(beam)
        (x, y) = self.rearrangeBeamTraceForPlotting(beamTrace)
        axes.plot(x, y, 'r', linewidth=1)
        axes.plot(x, [-v for v in y], 'r', linewidth=1)
github DCC-Lab / RayTracing / raytracing / abcd.py View on Github external
is the image? Distance after the element by which a ray
        must travel to reach the conjugate plane of the front of
        the element. A positive distance means the image is "distance"
        beyond the back of the element (or to the right, or after).

        M2 = Space(distance)*M1
        # M2.isImaging == True

        """

        if self.D == 0:
            distance = float("+inf")
            conjugateMatrix = None # Unable to compute with inf
        else:
            distance = -self.B / self.D
            conjugateMatrix = Space(d=distance) * self

        return (distance, conjugateMatrix)
github DCC-Lab / RayTracing / raytracing / abcd.py View on Github external
def backwardConjugate(self):
        """ With an image at the back edge of the element,
        where is the object ? Distance before the element by
        which a ray must travel to reach the conjugate plane at
        the back of the element. A positive distance means the
        object is "distance" in front of the element (or to the
        left, or before).

        M2 = M1*Space(distance)
        # M2.isImaging == True

        """
        if self.A == 0:
            return (None, None)
        distance = -self.B / self.A
        conjugateMatrix = self * Space(d=distance)
        return (distance, conjugateMatrix)
github DCC-Lab / RayTracing / raytracing / abcd.py View on Github external
def __init__(self, d, n=1, diameter=float('+Inf'), label=''):
        super(Space, self).__init__(A=1,
                                    B=float(d),
                                    C=0,
                                    D=1,
                                    physicalLength=d,
                                    frontVertex=None,
                                    backVertex=None,
                                    frontIndex=n,
                                    backIndex=n, 
                                    apertureDiameter=diameter,
                                    label=label)
github DCC-Lab / RayTracing / raytracing / abcd.py View on Github external
def drawBeamTrace(self, axes, beam):
        """ Draw beam trace corresponding to input beam 
        Because the laser beam diffracts through space, we cannot
        simply propagate the beam over large distances and trace it
        (as opposed to rays, where we can). We must split Space() 
        elements into sub elements to watch the beam size expand.
        
        We arbitrarily split Space() elements into 100 sub elements
        before plotting.
        """

        highResolution = ImagingPath()
        for element in self.elements:
            if isinstance(element, Space):
                for i in range(100):
                    highResolution.append(Space(d=element.L/100, 
                                                n=element.frontIndex))
            else:
                highResolution.append(element)


        beamTrace = highResolution.trace(beam)
        (x, y) = self.rearrangeBeamTraceForPlotting(beamTrace)
        axes.plot(x, y, 'r', linewidth=1)
        axes.plot(x, [-v for v in y], 'r', linewidth=1)
github DCC-Lab / RayTracing / raytracing / abcd.py View on Github external
def transferMatrix(self, upTo=float('+Inf')):
        """ Returns a Matrix() corresponding to a partial propagation
        if the requested distance is smaller than the length of this element"""
        distance = upTo
        if distance < self.L:
            return Space(distance)
        else:
            return self

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 3 months ago

Package Health Score

64 / 100
Full package analysis