Exemplo n.º 1
0
    def setUp(self):
        """
        This is automatically called by the unittest suite when the class is created.

        This set up assumes the following:

            Black Hole spin = 0.8
            Sensor Shape = 10 x 10

            Camera Properties:
                - r     = 10
                - theta = 1.415
                - phi   = 0

            Ray Properties:

                - ThetaCS = 1.445,
                - PhiCS   = -0.659734

        This properties generate a ray that curves around the black hole and comes back.
        The initial conditions and black hole properties are selected in a way that the
        ray is very unstable in the sense that a little variation of this set-up makes
        the ray to end in the horizon. This is very good to test numerical stability.
        """

        # Black hole constants
        spin = 0.8
        innerDiskRadius = 1
        outerDiskRadius = 1

        # Camera position
        camR = 10
        camTheta = 1.415
        camPhi = 0

        # Camera lens properties
        camFocalLength = 3
        camSensorShape = (10, 10)  # (Rows, Columns)
        camSensorSize = (2, 2)  # (Height, Width)

        # Create the black hole, the camera and the metric with the constants
        # above
        blackHole = BlackHole(spin, innerDiskRadius, outerDiskRadius)
        camera = Camera(camR, camTheta, camPhi, camFocalLength, camSensorShape, camSensorSize)
        kerr = KerrMetric(camera, blackHole)

        # Set camera's speed (it needs the kerr metric constants)
        camera.setSpeed(kerr, blackHole)

        # Monky-patch the raytracer with the overrider

        RayTracer.override_initial_conditions = override_initial_conditions
        RayTracer.collect_rays = collect_rays

        # Create the raytracer!
        self.rayTracer = RayTracer(camera, kerr, blackHole)

        # Override the initial conditions of the raytracer using the
        self.rayTracer.override_initial_conditions(10, 1.415, 0, 1.445, -0.659734)
Exemplo n.º 2
0
    outerDiskRadius = 20

    # Camera position
    camR = 30
    camTheta = 1.511
    camPhi = 0

    # Camera lens properties
    camFocalLength = 1.5
    camSensorShape = (1000, 1500)  # (Rows, Columns)
    camSensorSize = (2, 3)       # (Height, Width)

    # Create the black hole, the camera and the metric with the constants
    # above
    blackHole = BlackHole(spin, innerDiskRadius, outerDiskRadius)
    camera = Camera(camR, camTheta, camPhi, camFocalLength, camSensorShape,
                    camSensorSize)
    kerr = KerrMetric(camera, blackHole)

    # Set camera's speed (it needs the kerr metric constants)
    camera.setSpeed(kerr, blackHole)

    # Create the raytracer!
    rayTracer = RayTracer(camera, kerr, blackHole)
    rayTracer.rayTrace(-170, kernelCalls=1)

    # Load the textures
    disk = mimg.imread('../../Res/Textures/adisk.png')[:, :, :3]
    sphere = mimg.imread('../../Res/Textures/milkyWay.png')[:, :, :3]

    # Create the image
    rayTracer.texturedImage(disk.astype(np.float64), sphere.astype(np.float64))
Exemplo n.º 3
0
def main():
    camera = Camera(1600, 900, msaa=1)
    plt.imsave('out.png', camera.render(ray_color))