コード例 #1
0
ファイル: test_optics.py プロジェクト: jasminef/tracer
 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))
コード例 #2
0
ファイル: test_optics.py プロジェクト: jasminef/tracer
 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))
コード例 #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))
コード例 #4
0
ファイル: test_optics.py プロジェクト: jasminef/tracer
 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))
コード例 #5
0
ファイル: test_optics.py プロジェクト: jasminef/tracer
 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))
コード例 #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))
コード例 #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))
コード例 #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))
コード例 #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