def test_Angle_libre(): x = random() a = Angle_libre(x) assertAlmostEqual(a.deg, x*180/math.pi) assertAlmostEqual(a.grad, x*200/math.pi) assertAlmostEqual(a.rad, x) assertAlmostEqual(a.val, x) assertAlmostEqual(math.sin(a.val), math.sin(x)) assertAlmostEqual(math.cos(a.val), math.cos(x)) assertAlmostEqual(math.tan(a.val), math.tan(x)) y = x*180/math.pi a = Angle_libre(y, u"°") assertAlmostEqual(a.deg, y) assertAlmostEqual(a.grad, x*200/math.pi) assertAlmostEqual(a.rad, x) assertNotAlmostEqual(a.val, a.deg) assertAlmostEqual(u_sin(a), math.sin(x)) assertAlmostEqual(u_cos(a), math.cos(x)) assertAlmostEqual(u_tan(a), math.tan(x)) a.unite = "g" assertNotAlmostEqual(a.val, a.grad) b = Angle_libre(u"45°") assertAlmostEqual(b.rad, math.pi/4) f = Feuille() f.objets.A = Point(40, 20) f.objets.k = Variable("A.x+5") f.objets.c = Angle_libre(f.objets.k, "d") f.objets.d = Angle_libre("A.x+5", "d") assert(f.objets.c.rad is not None) assertAlmostEqual(b.rad, f.objets.c.rad) assertAlmostEqual(f.objets.d.rad, f.objets.c.rad)
def test_Angle_libre(): x = random() a = Angle_libre(x) assertAlmostEqual(a.deg, x * 180 / math.pi) assertAlmostEqual(a.grad, x * 200 / math.pi) assertAlmostEqual(a.rad, x) assertAlmostEqual(a.val, x) assertAlmostEqual(math.sin(a.val), math.sin(x)) assertAlmostEqual(math.cos(a.val), math.cos(x)) assertAlmostEqual(math.tan(a.val), math.tan(x)) y = x * 180 / math.pi a = Angle_libre(y, u"°") assertAlmostEqual(a.deg, y) assertAlmostEqual(a.grad, x * 200 / math.pi) assertAlmostEqual(a.rad, x) assertNotAlmostEqual(a.val, a.deg) assertAlmostEqual(u_sin(a), math.sin(x)) assertAlmostEqual(u_cos(a), math.cos(x)) assertAlmostEqual(u_tan(a), math.tan(x)) a.unite = "g" assertNotAlmostEqual(a.val, a.grad) b = Angle_libre(u"45°") assertAlmostEqual(b.rad, math.pi / 4) f = Feuille() f.objets.A = Point(40, 20) f.objets.k = Variable("A.x+5") f.objets.c = Angle_libre(f.objets.k, "d") f.objets.d = Angle_libre("A.x+5", "d") assert (f.objets.c.rad is not None) assertAlmostEqual(b.rad, f.objets.c.rad) assertAlmostEqual(f.objets.d.rad, f.objets.c.rad)
def test_Angle_libre(): x = random() a = Angle_libre(x) assertAlmostEqual(a.deg, x*180/math.pi) assertAlmostEqual(a.grad, x*200/math.pi) assertAlmostEqual(a.rad, x) assertAlmostEqual(a.val, x) assertAlmostEqual(math.sin(a.val), math.sin(x)) assertAlmostEqual(math.cos(a.val), math.cos(x)) assertAlmostEqual(math.tan(a.val), math.tan(x)) y = x*180/math.pi a = Angle_libre(y, u"°") assertAlmostEqual(a.deg, y) assertAlmostEqual(a.grad, x*200/math.pi) assertAlmostEqual(a.rad, x) assertNotAlmostEqual(a.val, a.deg) assertAlmostEqual(u_sin(a), math.sin(x)) assertAlmostEqual(u_cos(a), math.cos(x)) assertAlmostEqual(u_tan(a), math.tan(x)) a.unite = "g" assertNotAlmostEqual(a.val, a.grad) b = Angle_libre(u"45°") assertAlmostEqual(b.rad, math.pi/4) ## print "%% FEUILLE %%" ## f = geolib.Feuille() ## print f, type(f) ## p = Point(40, 20) ## print p, type(p), id(p) ## f.objets.A = p ## print f.objets.A, type(f.objets.A), id(f.objets.A) ## v = Variable("A.x+5") ## print v, type(v) ## f.objets.k = v ## f.objets.c = Angle_libre(f.objets.k, "d") ## assertAlmostEqual(b.rad, c.rad) f = Feuille() f.objets.A = Point(40, 20) f.objets.k = Variable("A.x+5") f.objets.c = Angle_libre(f.objets.k, "d") f.objets.d = Angle_libre("A.x+5", "d") assert(f.objets.c.rad is not None) assertAlmostEqual(b.rad, f.objets.c.rad) assertAlmostEqual(f.objets.d.rad, f.objets.c.rad)