Esempio n. 1
0
    def test01(self):
        x = rotation.new_rotation_matrix(0,0,0)
        self.assertAlmostRelativeEquals(x, ((1,0,0),(0,1,0),(0,0,1)))

        x = rotation.new_rotation_matrix(numpy.pi,0,0)
        print x
        self.assertAlmostRelativeEquals(x, ((1,0,0),(0,-1,0),(0,0,-1)))
        x = rotation.new_rotation_matrix(0,numpy.pi,0)
        self.assertAlmostRelativeEquals(x, ((-1,0,0),(0,1,0),(0,0,-1)))
        x = rotation.new_rotation_matrix(0, 0, numpy.pi)
        self.assertAlmostRelativeEquals(x, ((-1,0,0),(0,-1,0),(0,0,1)))
Esempio n. 2
0
    def test01(self):
        x = rotation.new_rotation_matrix(0, 0, 0)
        self.assertAlmostRelativeEquals(x, ((1, 0, 0), (0, 1, 0), (0, 0, 1)))

        x = rotation.new_rotation_matrix(numpy.pi, 0, 0)
        print(x)
        self.assertAlmostRelativeEquals(x, ((1, 0, 0), (0, -1, 0), (0, 0, -1)))
        x = rotation.new_rotation_matrix(0, numpy.pi, 0)
        self.assertAlmostRelativeEquals(x, ((-1, 0, 0), (0, 1, 0), (0, 0, -1)))
        x = rotation.new_rotation_matrix(0, 0, numpy.pi)
        self.assertAlmostRelativeEquals(x, ((-1, 0, 0), (0, -1, 0), (0, 0, 1)))
Esempio n. 3
0
 def test02(self):
     x = rotation.new_rotation_matrix(numpy.pi / 2.0, 0, 0)
     print x
     self.assertAlmostRelativeEquals(x, ((1, 0, 0), (0, 0, -1), (0, 1, 0)))
     x = rotation.new_rotation_matrix(0, numpy.pi / 2.0, 0)
     print x
     self.assertAlmostRelativeEquals(x, ((0, 0, 1), (0, 1, 0), (-1, 0, 0)))
     x = rotation.new_rotation_matrix(0, 0, numpy.pi / 2.0)
     print x
     self.assertAlmostRelativeEquals(x, ((0, -1, 0), (1, 0, 0), (0, 0, 1)))
     x = rotation.new_rotation_matrix(numpy.pi / 2.0, numpy.pi / 2.0, 0)
     print x
     self.assertAlmostRelativeEquals(x, ((0, 1, 0), (0, 0, -1), (-1, 0, 0)))
Esempio n. 4
0
 def test10(self):
     print "test conservation of dot, transformation of cross"
     p=particles.Particles(1)
     p.position=[1.,2.,3.]
     p.velocity=[-4,5,6.]
     
     dot1=p[0].position.dot(p[0].velocity)
     cross1=numpy.cross(p[0].position,p[0].velocity)
     
     rm=rotation.new_rotation_matrix(0.1,0.5,3.5)
     p.rotate(0.1,0.5,3.5)
     
     dot2=p[0].position.dot(p[0].velocity)
     cross2=numpy.cross(p[0].position,p[0].velocity)
     
     self.assertAlmostRelativeEquals(dot1,dot2)
     self.assertAlmostRelativeEquals(cross2,cross1.dot(numpy.linalg.inv(rm)))
Esempio n. 5
0
    def test10(self):
        print "test conservation of dot, transformation of cross"
        p = particles.Particles(1)
        p.position = [1., 2., 3.]
        p.velocity = [-4, 5, 6.]

        dot1 = p[0].position.dot(p[0].velocity)
        cross1 = numpy.cross(p[0].position, p[0].velocity)

        rm = rotation.new_rotation_matrix(0.1, 0.5, 3.5)
        p.rotate(0.1, 0.5, 3.5)

        dot2 = p[0].position.dot(p[0].velocity)
        cross2 = numpy.cross(p[0].position, p[0].velocity)

        self.assertAlmostEquals(dot1, dot2, 14)
        self.assertAlmostEquals(cross2, cross1.dot(numpy.linalg.inv(rm)), 14)
Esempio n. 6
0
 def test11(self):
     print "test conservation of dot, transformation of cross with units"
     p=particles.Particles(5)
     p.position=[1.,2.,3.] | units.km
     p.velocity=[-4,5,6.] | units.kms
     
     p[1:].position*=0
     p[1:].velocity*=0
             
     dot1=p[0].position.dot(p[0].velocity)
     cross1=p[0].position.cross(p[0].velocity)
     
     rm=rotation.new_rotation_matrix(0.1,0.5,3.5)
     p.rotate(0.1,0.5,3.5)
     
     dot2=p[0].position.dot(p[0].velocity)
     cross2=p[0].position.cross(p[0].velocity)
             
     self.assertAlmostRelativeEquals(dot1.value_in(units.km**2/units.s),dot2.value_in(units.km**2/units.s))
     self.assertAlmostRelativeEquals(cross2.value_in(units.km**2/units.s),cross1.dot(numpy.linalg.inv(rm)).value_in(units.km**2/units.s))
Esempio n. 7
0
 def test11(self):
     print "test conservation of dot, transformation of cross with units"
     p=particles.Particles(5)
     p.position=[1.,2.,3.] | units.km
     p.velocity=[-4,5,6.] | units.kms
     
     p[1:].position*=0
     p[1:].velocity*=0
             
     dot1=p[0].position.dot(p[0].velocity)
     cross1=p[0].position.cross(p[0].velocity)
     
     rm=rotation.new_rotation_matrix(0.1,0.5,3.5)
     p.rotate(0.1,0.5,3.5)
     
     dot2=p[0].position.dot(p[0].velocity)
     cross2=p[0].position.cross(p[0].velocity)
             
     self.assertAlmostEquals(dot1.value_in(units.km**2/units.s),dot2.value_in(units.km**2/units.s),14)
     self.assertAlmostEquals(cross2.value_in(units.km**2/units.s),cross1.dot(numpy.linalg.inv(rm)).value_in(units.km**2/units.s),13)