mirror of
https://github.com/BreizhHardware/py_A2.git
synced 2026-03-18 21:30:52 +01:00
TP nombre complexe
This commit is contained in:
@@ -82,5 +82,6 @@ def test_polycreux():
|
|||||||
print(e)
|
print(e)
|
||||||
print(pc(1) + pc(0))
|
print(pc(1) + pc(0))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -41,13 +41,35 @@ def dessiner_cercle(x, y, r):
|
|||||||
|
|
||||||
def cercle_dans_cercle():
|
def cercle_dans_cercle():
|
||||||
plot.axis("equal")
|
plot.axis("equal")
|
||||||
fig, ax = plot.subplots()
|
for i in range(1, 11):
|
||||||
for i in range(10):
|
dessiner_cercle(0, 0, i / 10)
|
||||||
cercle = dessiner_cercle(0, 0, i + 1)
|
|
||||||
ax.add_patch(cercle)
|
|
||||||
plot.show()
|
plot.show()
|
||||||
|
|
||||||
|
|
||||||
|
def carre_de_cercle(longueur, rayon=1):
|
||||||
|
# Dessine un carré de coté coté avec des cercles de rayon coté/2
|
||||||
|
x = np.linspace(rayon, longueur - rayon, int(longueur / (2 * rayon)))
|
||||||
|
y = np.linspace(rayon, longueur - rayon, int(longueur / (2 * rayon)))
|
||||||
|
X, Y = np.meshgrid(x, y)
|
||||||
|
plot.scatter(X, Y, s=np.pi * (2 * rayon) ** 2)
|
||||||
|
plot.gca().set_aspect('equal', adjustable='box')
|
||||||
|
plot.show()
|
||||||
|
|
||||||
|
|
||||||
|
def cercle_de_plus_en_plus_petit():
|
||||||
|
plot.axis("equal")
|
||||||
|
x = 0
|
||||||
|
for i in range(5):
|
||||||
|
x -= 2 * i - 1
|
||||||
|
dessiner_cercle(x, 0, i)
|
||||||
|
plot.show()
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_avec_cercle():
|
||||||
|
for i in range(10):
|
||||||
|
for j in range(i):
|
||||||
|
dessiner_cercle(j, i, 0.5)
|
||||||
|
plot.show()
|
||||||
|
|
||||||
|
|
||||||
# Jeu de test
|
# Jeu de test
|
||||||
@@ -64,3 +86,6 @@ print(cos_a) # affiche [ 0.54030231 -0.66939722 -0.9899925 ]
|
|||||||
cercle = dessiner_cercle(0, 0, 1)
|
cercle = dessiner_cercle(0, 0, 1)
|
||||||
cercle.show()
|
cercle.show()
|
||||||
cercle_dans_cercle()
|
cercle_dans_cercle()
|
||||||
|
carre_de_cercle(10, 1)
|
||||||
|
cercle_de_plus_en_plus_petit()
|
||||||
|
triangle_avec_cercle()
|
||||||
|
|||||||
101
TP Nombres Complexes/tp15.py
Normal file
101
TP Nombres Complexes/tp15.py
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import math
|
||||||
|
import cmath
|
||||||
|
import turtle
|
||||||
|
import time
|
||||||
|
|
||||||
|
z = 1 + 3j
|
||||||
|
print(z.real)
|
||||||
|
print(z.imag)
|
||||||
|
print(z.conjugate())
|
||||||
|
module = abs(4 + 3j)
|
||||||
|
print(module)
|
||||||
|
print(complex(1))
|
||||||
|
print(complex(1, 2))
|
||||||
|
print(complex(imag=1))
|
||||||
|
# complex('1+1 j')
|
||||||
|
# complex ('1 + 1 j')
|
||||||
|
|
||||||
|
# math.sqrt(-1)
|
||||||
|
print(cmath.sqrt(-1))
|
||||||
|
|
||||||
|
c = cmath.phase(complex(-1.0, 0.0))
|
||||||
|
print(c)
|
||||||
|
c = cmath.phase(complex(-1.0, -0.0))
|
||||||
|
print(c)
|
||||||
|
|
||||||
|
c = cmath.polar(1j)
|
||||||
|
print(c)
|
||||||
|
|
||||||
|
c = cmath.exp(1j * cmath.pi / 2)
|
||||||
|
print(c)
|
||||||
|
|
||||||
|
|
||||||
|
def triangle():
|
||||||
|
turtle.forward(100)
|
||||||
|
turtle.left(120)
|
||||||
|
turtle.forward(100)
|
||||||
|
turtle.left(120)
|
||||||
|
turtle.forward(100)
|
||||||
|
turtle.left(120)
|
||||||
|
|
||||||
|
|
||||||
|
def carre():
|
||||||
|
turtle.left(45)
|
||||||
|
turtle.forward(95)
|
||||||
|
turtle.left(90)
|
||||||
|
turtle.forward(95)
|
||||||
|
turtle.left(90)
|
||||||
|
turtle.forward(95)
|
||||||
|
turtle.left(90)
|
||||||
|
turtle.forward(95)
|
||||||
|
turtle.left(90)
|
||||||
|
|
||||||
|
|
||||||
|
def pyntagon():
|
||||||
|
for i in range(5):
|
||||||
|
turtle.forward(100)
|
||||||
|
turtle.left(72)
|
||||||
|
|
||||||
|
|
||||||
|
def hexagon():
|
||||||
|
for i in range(6):
|
||||||
|
turtle.forward(100)
|
||||||
|
turtle.left(60)
|
||||||
|
|
||||||
|
|
||||||
|
def octogon():
|
||||||
|
for i in range(8):
|
||||||
|
turtle.forward(100)
|
||||||
|
turtle.left(45)
|
||||||
|
|
||||||
|
|
||||||
|
def circle():
|
||||||
|
for i in range(20):
|
||||||
|
turtle.forward(10)
|
||||||
|
turtle.left(360 / 20)
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_filled():
|
||||||
|
turtle.begin_fill()
|
||||||
|
triangle()
|
||||||
|
turtle.end_fill()
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_filled_rotation():
|
||||||
|
while True:
|
||||||
|
turtle.begin_fill()
|
||||||
|
triangle()
|
||||||
|
turtle.end_fill()
|
||||||
|
turtle.right(math.degrees(math.pi / 10))
|
||||||
|
turtle.clear()
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
||||||
|
# triangle()
|
||||||
|
# carre()
|
||||||
|
# pyntagon()
|
||||||
|
# hexagon()
|
||||||
|
# octogon()
|
||||||
|
# circle()
|
||||||
|
# triangle_filled()
|
||||||
|
triangle_filled_rotation()
|
||||||
Reference in New Issue
Block a user