Exemplo n.º 1
0
    def testRotateAroundAxis(self):
        vector_x = Vector(1, 0, 0)
        vector_y = Vector(0, 1, 0)
        vector_z = Vector(0, 0, 1)
        vector_minus_x = Vector(-1, 0, 0)
        vector_minus_y = Vector(0, -1, 0)
        vector_minus_z = Vector(0, 0, -1)

        result = vector_x.rotateAroundAxis(vector_z, pi)
        self.assertTrue(result == vector_minus_x)

        result = vector_x.rotateAroundAxis(vector_z, pi / 2.0)
        self.assertTrue(result == vector_y)

        result = vector_x.rotateAroundAxis(vector_minus_z, pi / 2.0)
        self.assertTrue(result == vector_minus_y)

        result = vector_x.addVector(vector_y).rotateAroundAxis(vector_z, pi)
        self.assertTrue(result == vector_minus_x.addVector(vector_minus_y))

        result = vector_z.rotateAroundAxis(vector_z, pi)
        self.assertTrue(result == vector_z)

        result = vector_z.rotateAroundAxis(vector_x, pi / 2.0)
        self.assertTrue(result == vector_minus_y)

        result = vector_z.addVector(vector_x).rotateAroundAxis(vector_y, pi / 2.0)
        self.assertTrue(result == vector_x.addVector(vector_minus_z))
Exemplo n.º 2
0
    def testAddVector(self):
        vector_1 = Vector(1, 2, 3)
        vector_2 = Vector(-1, 2, 1)
        vector_sum = Vector(0, 4, 4)

        result = vector_1.addVector(vector_2)

        self.assertTrue(result == vector_sum)
 def vectorKh(self, energy):
     """
     returns Kh verifying Laue equation
     """
     return Vector.addVector(self.vectorK0(energy), self.vectorH())