import numpy as np
import matplotlib.pyplot as plt
P = np.array([1, 2])
Q = np.array([-3, -1])
R = np.array([5, 5])
d = np.array([4, 3])
t = np.linspace(-2, 2, 1000)
M = np.array([1, 2])
points = M[:, None] + d[:, None] * t
def dist(dt):
return abs(3*dt[0] + (-4)*dt[1] + 5) / np.sqrt(3**2 + (-4)**2)
print(f"Расстояние от точки P до прямой: {dist(P)}")
print(f"Расстояние от точки Q до прямой: {dist(Q)}")
print(f"Расстояние от точки R до прямой: {dist(R)}")
plt.plot(points[0], points[1], label="$a$")
plt.scatter(P[0], P[1], label="$P$")
plt.scatter(Q[0], Q[1], label="$Q$")
plt.scatter(R[0], R[1], label="$R$")
plt.axhline(0)
plt.axvline(0)
plt.xlabel("x")
plt.ylabel("y")
plt.grid()
plt.legend()
plt.show()