How to use the raytracing.graphicComponents.BezierCurve 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 / graphicComponents.py View on Github external
def bezierCurves(self) -> List[BezierCurve]:
        h = self.halfHeight
        v1 = self.x

        if self.surface.R == float("+inf"):
            return [BezierCurve([(v1, -h), (v1, h)])]

        R1 = self.surface.R
        phi1 = math.asin(h / abs(R1))
        delta1 = R1 * (1.0 - math.cos(phi1))
        ctl1 = abs((1.0 - math.cos(phi1)) / math.sin(phi1) * R1)
        corner1 = v1 + delta1

        return [BezierCurve([(corner1, -h), (v1, -ctl1), (v1, 0)]),
                BezierCurve([(v1, 0), (v1, ctl1), (corner1, h)])]
github DCC-Lab / RayTracing / raytracing / graphicComponents.py View on Github external
def bezierCurves(self) -> List[BezierCurve]:
        """ An aperture component is defined as a straight line at 'y' and '-y'. """
        if self.width <= 0.01:
            coordsTop = [(self.x - 0.005, self.y), (self.x + 0.005, self.y)]
            coordsBottom = [(self.x - 0.005, -self.y), (self.x + 0.005, -self.y)]
        else:
            coordsTop = [(self.x, self.y), (self.x + self.width, self.y)]
            coordsBottom = [(self.x, -self.y), (self.x + self.width, -self.y)]

        return [BezierCurve(coordsTop), BezierCurve(coordsBottom)]
github DCC-Lab / RayTracing / raytracing / graphicComponents.py View on Github external
if self.surfaceA.R == float("+inf"):
            self.corners = [v1]
            return [BezierCurve([(v1, -h), (v1, h)])]

        R1 = self.surfaceA.R
        phi1 = math.asin(h / abs(R1))
        delta1 = R1 * (1.0 - math.cos(phi1))
        ctl1 = abs((1.0 - math.cos(phi1)) / math.sin(phi1) * R1)
        corner1 = v1 + delta1

        self.corners = [corner1]
        if self.surfaceA.L == 0:  # realistic thin lens exception
            self.surfaceA.L = delta1 * 2

        return [BezierCurve([(corner1, -h), (v1, -ctl1), (v1, 0)]),
                BezierCurve([(v1, 0), (v1, ctl1), (corner1, h)])]
github DCC-Lab / RayTracing / raytracing / graphicComponents.py View on Github external
def linearBezierCurvesFrom(controlPoints: List[Tuple]) -> List[BezierCurve]:
        """ A list of linear bezier curves that go through all points.

        Arguments
        ---------
        controlPoints: List
            The coordinates in (x, y) tuples that define all required linear bezier curves.
        """

        bezierCurves = []
        for i, cpA in enumerate(controlPoints[:-1]):
            cpB = controlPoints[i+1]
            bezierCurves.append(BezierCurve([cpA, cpB]))
        return bezierCurves
github DCC-Lab / RayTracing / raytracing / graphicComponents.py View on Github external
if self.surfaceB.R == float("+inf"):
            self.corners.append(v2)
            return [BezierCurve([(self.corners[0], h), (v2, h)]),
                    BezierCurve([(v2, h), (v2, -h)]),
                    BezierCurve([(v2, -h), (self.corners[0], -h)])]

        R2 = self.surfaceB.R
        phi2 = math.asin(h / abs(R2))
        delta2 = R2 * (1.0 - math.cos(phi2))
        ctl2 = abs((1.0 - math.cos(phi2)) / math.sin(phi2) * R2)
        corner2 = v2 + delta2
        self.corners.append(corner2)

        return [BezierCurve([(self.corners[0], h), (corner2, h)]),
                BezierCurve([(corner2, h), (v2, ctl2), (v2, 0)]),
                BezierCurve([(v2, 0), (v2, -ctl2), (corner2, -h)]),
                BezierCurve([(corner2, -h), (self.corners[0], -h)])]