in process

This commit is contained in:
nik
2025-10-13 23:04:14 +03:00
parent b52b991289
commit 2589f778c1
8 changed files with 381 additions and 120 deletions

View File

@@ -1,7 +1,26 @@
from sys import argv
import matplotlib.pyplot as plt
import numpy as np
def read_points(filename: str) -> list[tuple[float, float, str]]:
points = []
with open(filename, "r", encoding="utf-8") as f:
for line in f:
line = line.strip()
if line and not line.startswith("#"):
parts = line.split()
if len(parts) >= 3:
x = float(parts[0])
y = float(parts[1])
label = parts[2]
points.append((x, y, label))
return points
def main() -> None:
points = read_points(argv[1])
plt.figure(figsize=(8.27, 11.69))
plt.xlim(0, 30)
@@ -11,43 +30,19 @@ def main() -> None:
plt.xticks(range(0, 31, 2))
plt.yticks(range(0, 21, 2))
points = [
(2, 2, "1.89"),
(2.5, 6, "1.89B"),
(2.8, 10, "1.89"),
(2.7, 14, "1.89"),
(2.0, 18, "1.89"),
(6.8, 2, "3.89"),
(6.8, 6, "3.89"),
(7.0, 10, "3.89"),
(6.9, 14, "3.89"),
(7.2, 18, "3.89"),
(11.8, 2, "5.89"),
(12.2, 6, "5.89"),
(12.5, 10, "5.89"),
(12.8, 14, "5.89"),
(12.6, 18, "5.89"),
(16.7, 2, "7.89"),
(16.8, 6, "7.89"),
(16.5, 10, "7.89"),
(16.3, 14, "7.89"),
(16.3, 18, "7.89"),
(21.3, 2, "9.89"),
(21.3, 6, "9.89"),
(21.3, 10, "9.89"),
(21.1, 14, "9.89"),
(21.0, 18, "9.89"),
(26.1, 2, "11.89"),
(25.7, 6, "11.89"),
(25.6, 10, "11.89"),
(25.7, 14, "11.89"),
(26.0, 18, "11.89"),
]
for x, y, label in points:
plt.scatter(x, y, color="red", s=15)
plt.text(x + 0.3, y + 0.3, label, fontsize=9)
if int(argv[2]):
theta = np.linspace(0, 2 * np.pi, 200)
cx, cy = 15, 9
for r in [5, 6]:
x = cx + r * np.cos(theta)
y = cy + r * np.sin(theta)
plt.plot(x, y, color="blue", linewidth=1)
plt.xlabel("X (см)")
plt.ylabel("Y (см)")
plt.title("Эквипотенциальные точки")