Example #1
0
 def runTest(self):
     dir = N.array([[1, 1, 0], [-1, 1, 0], [-1, -1, 0], [1, -1, 0]]).T / math.sqrt(2)
     normal = N.array([[0, 0, 1]]).T
     
     reflection = optics.reflections(dir, normal)
     self.failUnless(N.allclose(reflection, dir), 
         "Reflection is\n" + str(reflection) + "\nbut should be\n" + str(dir))
Example #2
0
 def runTest(self):
     dir = N.array([[1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1]]).T / math.sqrt(3)
     normal = N.array([[0, 0, 1]]).T
     correct_reflection = N.array([[1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1]]).T / math.sqrt(3)
     
     reflection = optics.reflections(dir, normal)
     self.failUnless((reflection == correct_reflection).all(), 
         "Reflection is\n" + str(reflection) + "\nbut should be\n" + str(correct_reflection))
Example #3
0
    def runTest(self):
        dir = N.array([[1, 1, 0], [-1, 1, 0], [-1, -1, 0], [1, -1, 0]
                       ]).T / math.sqrt(2)
        normal = N.array([[0, 0, 1]]).T

        reflection = optics.reflections(dir, normal)
        self.failUnless(
            N.allclose(reflection, dir), "Reflection is\n" + str(reflection) +
            "\nbut should be\n" + str(dir))
Example #4
0
 def runTest(self):
     """A single beam at 45 degs to the surface reflects correctly"""
     dir = N.array([[0, 1, -1]]).T / math.sqrt(2)
     normal = N.array([[0, 0, 1]]).T
     correct_reflection = N.array([[0, 1, 1]]).T / math.sqrt(2)
     
     reflection = optics.reflections(dir, normal)
     self.failUnless((reflection == correct_reflection).all(), 
         "Reflection is\n" + str(reflection) + "\nbut should be\n" + str(correct_reflection))
Example #5
0
 def runTest(self):
     dir = N.array([[1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1]]).T / math.sqrt(3)
     # The normals are selected to reflect all the rays to the same direction.
     normal = N.array([[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]]).T / N.sqrt([1, 2, 3, 2])
     correct_reflection = N.tile([1, 1, 1], (4,1)).T / math.sqrt(3)
     
     reflection = optics.reflections(dir, normal)
     self.failUnless(N.allclose(reflection, correct_reflection), 
         "Reflection is\n" + str(reflection) + "\nbut should be\n" + str(correct_reflection))
Example #6
0
    def runTest(self):
        """A single beam at 45 degs to the surface reflects correctly"""
        dir = N.array([[0, 1, -1]]).T / math.sqrt(2)
        normal = N.array([[0, 0, 1]]).T
        correct_reflection = N.array([[0, 1, 1]]).T / math.sqrt(2)

        reflection = optics.reflections(dir, normal)
        self.failUnless((reflection == correct_reflection).all(),
                        "Reflection is\n" + str(reflection) +
                        "\nbut should be\n" + str(correct_reflection))
Example #7
0
    def runTest(self):
        dir = N.array([[1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1]
                       ]).T / math.sqrt(3)
        normal = N.array([[0, 0, 1]]).T
        correct_reflection = N.array([[1, 1, 1], [-1, 1, 1], [-1, -1, 1],
                                      [1, -1, 1]]).T / math.sqrt(3)

        reflection = optics.reflections(dir, normal)
        self.failUnless((reflection == correct_reflection).all(),
                        "Reflection is\n" + str(reflection) +
                        "\nbut should be\n" + str(correct_reflection))
Example #8
0
    def runTest(self):
        dir = N.array([[1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1]
                       ]).T / math.sqrt(3)
        # The normals are selected to reflect all the rays to the same direction.
        normal = N.array([[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]
                          ]).T / N.sqrt([1, 2, 3, 2])
        correct_reflection = N.tile([1, 1, 1], (4, 1)).T / math.sqrt(3)

        reflection = optics.reflections(dir, normal)
        self.failUnless(
            N.allclose(reflection, correct_reflection), "Reflection is\n" +
            str(reflection) + "\nbut should be\n" + str(correct_reflection))
Example #9
0
    def get_outgoing(self,  selector):
        """Generates a new ray bundle, which is the reflections/refractions of the
        user-selected rays out of the incoming ray-bundle that was previously 
        registered.
        Arguments: selector - a boolean array specifying which rays of the incoming
            bundle are still relevant.
        Returns: a RayBundle object with the new bundle, with vertices on the panel
            and directions according to optics laws.

        """
        vertices = N.dot(self.get_rotation()[:, :2],  self._current_params[:, selector]) + \
            self.get_location()[:, None]
        dirs = optics.reflections(self._current_bundle.get_directions()[:, selector],  
            self.get_rotation()[:, 2][:,None])
    
        outg = RayBundle()
        outg.set_vertices(vertices)
        outg.set_directions(dirs)
        return outg