def calctor(self, i, j, k, l): "return in radian" coords = self.coords return tools.torsionangle(coords[i], coords[j], coords[k], coords[l])
def test_torsionangle(self): a = numpy.array((0.0, 0.0, 0.0)) b = numpy.array((1.0, 0.0, 0.0)) c = numpy.array((1.0, 1.0, 0.0)) d = numpy.array((1.0, 1.0, 1.0)) t1 = tools.torsionangle(a, a, c, d) self.assertEqual(str(t1), 'nan') # t1 is nan t1 = tools.torsionangle(a, b, b, d) self.assertEqual(str(t1), 'nan') # t1 is nan t1 = tools.torsionangle(a, b, c, c) self.assertEqual(str(t1), 'nan') # t1 is nan t1 = tools.torsionangle(a, b, a, d) self.assertEqual(str(t1), 'nan') # t1 is nan t1 = tools.torsionangle(a, b, c, b) self.assertEqual(str(t1), 'nan') # t1 is nan self.assertAlmostEqual(math.degrees(tools.torsionangle(a, b, c, a)), 0.0) self.assertAlmostEqual(math.degrees(tools.torsionangle(a, b, c, d)), 90.0)
def is_pyramid(O, A, B, C, D): '''whether O(A, B, C, D) is a pyramid ''' return torsionangle(O, A, B, C) * torsionangle(O, A, B, D) > 0 \ or torsionangle(O, A, C, B) * torsionangle(O, A, C, D) > 0