How to use the raytracing.abcd.GaussianBeam 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 eigenModes(self):
        """
        Returns the two complex radii that are identical after a
        round trip, assuming the matrix of the LaserPath() is one
        round trip: you will need to duplicate elements in reverse
        and append them manually. 
        """
        b = self.D - self.A
        sqrtDelta = cmath.sqrt(b*b + 4.0 *self.B *self.C)
        
        q1 = (- b + sqrtDelta)/(2.0*self.C)
        q2 = (- b - sqrtDelta)/(2.0*self.C)

        return (GaussianBeam(q=q1), GaussianBeam(q=q2))
github DCC-Lab / RayTracing / raytracing / abcd.py View on Github external
def __mul__(self, rightSide):
        """Operator overloading allowing easy to read matrix multiplication

        For instance, with M1 = Matrix() and M2 = Matrix(), one can write
        M3 = M1*M2. With r = Ray(), one can apply the M1 transform to a ray
        with r = M1*r

        """
        if isinstance(rightSide, Matrix):
            return self.mul_matrix(rightSide)
        elif isinstance(rightSide, Ray):
            return self.mul_ray(rightSide)
        elif isinstance(rightSide, GaussianBeam):
            return self.mul_beam(rightSide)
        else:
            raise TypeError(
                "Unrecognized right side element in multiply: '{0}'\
                 cannot be multiplied by a Matrix".format(rightSide))
github DCC-Lab / RayTracing / raytracing / abcd.py View on Github external
def mul_beam(self, rightSideBeam):
        """ Multiplication of a coherent beam with complex radius
        of curvature q by a matrix.

        """
        q = rightSideBeam.q
        if rightSideBeam.n != self.frontIndex:
            print("Warning: the gaussian beam is not tracking the index of refraction properly")

        qprime = (complex(self.A) * q + complex(self.B) ) / (complex(self.C)*q + complex(self.D))
        
        outputBeam = GaussianBeam(q=qprime, wavelength=rightSideBeam.wavelength)
        outputBeam.z = self.L + rightSideBeam.z
        outputBeam.n = self.backIndex

        if abs(outputBeam.w) > self.apertureDiameter / 2:
            outputBeam.isClipped = True
        else:
            outputBeam.isClipped = rightSideBeam.isClipped

        return outputBeam