38 lines
846 B
Python
38 lines
846 B
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
from ex2 import gauss
|
|
from ex1 import resolve_up
|
|
|
|
if __name__ == '__main__':
|
|
A = np.array([
|
|
[-1, 5.6, 20.4],
|
|
[-1, 28, 26],
|
|
[-1, 8, 30]
|
|
], dtype=np.float32)
|
|
|
|
b = np.array([84.84, 361, 228.75], dtype=np.float32)
|
|
|
|
A_res, b_res = gauss(A, b)
|
|
print(f'A: {A_res}')
|
|
print(f'b: {b_res}')
|
|
|
|
x = resolve_up(A_res, b_res)
|
|
print(f'x: {x}')
|
|
|
|
fig, ax = plt.subplots()
|
|
cercles = [(2.8, 10.2, 5.2), (14, 13, 7), (4, 15, 3.5)]
|
|
|
|
for x, y, r in cercles:
|
|
cercle = plt.Circle((x, y), r, color='blue', fill=False)
|
|
ax.add_patch(cercle)
|
|
|
|
# Ajuster les limites du graphique
|
|
ax.set_xlim(-4, 22)
|
|
ax.set_ylim(4, 21)
|
|
ax.set_aspect('equal')
|
|
|
|
plt.title("Cercles tracés avec matplotlib")
|
|
plt.grid(True)
|
|
plt.show()
|