Esempio n. 1
0
 def test_angle_between_directions(self):
     d111 = HklDirection(1, 1, 1)
     d110 = HklDirection(1, 1, 0)
     d100 = HklDirection(1, 0, 0)
     dm111 = HklDirection(-1, 1, 1)
     self.assertAlmostEqual(
         d100.angle_with_direction(d110) * 180 / np.pi, 45.0)
     self.assertAlmostEqual(
         d111.angle_with_direction(d110) * 180 / np.pi, 35.26, 2)
     self.assertAlmostEqual(
         d111.angle_with_direction(dm111) * 180 / np.pi, 70.528, 2)
Esempio n. 2
0
 def test_angle_with_directions(self):
     (a, b, c) = (1.022, 0.596, 0.481)
     olivine = Lattice.orthorhombic(a, b, c)
     (h1, k1, l1) = (1., 1., 1.)
     (h2, k2, l2) = (3., 3., 2.)
     d1 = HklDirection(h1, k1, l1, olivine)
     d2 = HklDirection(h2, k2, l2, olivine)
     # compare with formula in orthorhombic lattice, angle must be 6.589 degrees
     angle = np.arccos(
         ((h1 * h2 * a**2) + (k1 * k2 * b**2) + (l1 * l2 * c**2)) /
         (np.sqrt(a**2 * h1**2 + b**2 * k1**2 + c**2 * l1**2) *
          np.sqrt(a**2 * h2**2 + b**2 * k2**2 + c**2 * l2**2)))
     self.assertAlmostEqual(d1.angle_with_direction(d2), angle)