import matplotlib.pyplot as plt
import numpy as np
# Define the rectangle ABCD
A = np.array([0, 0])
B = np.array([3, 0])
C = np.array([3, 2 * np.sqrt(3)])
D = np.array([0, 2 * np.sqrt(3)])
# Midpoint M of BC
M = (B + C) / 2
# Define point N on CD such that angle NMC = 30 degrees
# Let N be at (x, y) on CD, where x ranges from 0 to 3 and y = 2√3
# We will find N such that angle NMC = 30 degrees
# Use tangent to find the position of N
angle_NMC = np.radians(30)
# The slope of line MC
slope_MC = (C[1] - M[1]) / (C[0] - M[0])
# The slope of line NM using the angle
slope_NM = np.tan(angle_NMC)
# N is on line CD, where y = 2√3 and x is between 0 and 3.
# Equation relating N, M and C:
# slope_NM = (N[1] - M[1]) / (N[0] - M[0])
# We know N[1] = 2√3, so we can find N[0]:
# M coordinates
Mx, My = M
# y coordinate of N
Ny = 2 * np.sqrt(3)
# Calculate Nx using the slope
Nx = Mx + (Ny - My) / slope_NM
# Ensure N is within the bounds of CD
if 0 <= Nx <= 3:
N = np.array([Nx, Ny])
else:
raise ValueError("Calculated N is out of bounds on CD")
# Plotting the rectangle and points
plt.plot([A[0], B[0]], [A[1], B[1]], 'b-')
plt.plot([B[0], C[0]], [B[1], C[1]], 'b-')
plt.plot([C[0], D[0]], [C[1], D[1]], 'b-')
plt.plot([D[0], A[0]], [D[1], A[1]], 'b-')
# Plot points A, B, C, D, M, N
plt.plot(*A, 'ro')
plt.text(A[0], A[1], 'A', fontsize=12, ha='right')
plt.plot(*B, 'ro')
plt.text(B[0], B[1], 'B', fontsize=12, ha='right')
plt.plot(*C, 'ro')
plt.text(C[0], C[1], 'C', fontsize=12, ha='right')
plt.plot(*D, 'ro')
plt.text(D[0], D[1], 'D', fontsize=12, ha='right')
plt.plot(*M, 'go')
plt.text(M[0], M[1], 'M', fontsize=12, ha='left')
plt.plot(*N, 'mo')
plt.text(N[0], N[1], 'N', fontsize=12, ha='left')
# Set limits and aspect
plt.xlim(-1, 4)
plt.ylim(-1, 3)
plt.gca().set_aspect('equal', adjustable='box')
plt.title('Dreptunghi ABCD cu punctele M si N')
plt.grid()
plt.show()
import matplotlib.pyplot as plt
import numpy as np
# Define the rectangle ABCD
A = np.array([0, 0])
B = np.array([3, 0])
C = np.array([3, 2 * np.sqrt(3)])
D = np.array([0, 2 * np.sqrt(3)])
# Midpoint M of BC
M = (B + C) / 2
# Define the angle and calculate the position of N
angle_NMC = 30 # degrees
angle_NMC_rad = np.radians(angle_NMC)
# Point N is a point on line segment CD which means y-coordinate is constant at 2√3
y_N = C[1]
# We will calculate the position of N using trigonometry
# Using the definition of tangent in triangle NMC
# tan(angle) = opposite / adjacent
# In our case, opposite is difference in heights (MC height) which is x-coordinate difference because y is constant
# Calculate the horizontal distance (adjacent)
horizontal_distance = (C[0] - M[0]) * np.tan(angle_NMC_rad)
# Calculate N's x-coordinate
N_x = M[0] - horizontal_distance # Move leftward from M
# Ensuring N's x-coordinate is within the bounds of segment CD
if 0 <= N_x <= 3:
N = np.array([N_x, y_N])
else:
raise ValueError("Calculated N is out of bounds on CD")
# Plotting the rectangle and points
plt.plot([A[0], B[0]], [A[1], B[1]], 'b-')
plt.plot([B[0], C[0]], [B[1], C[1]], 'b-')
plt.plot([C[0], D[0]], [C[1], D[1]], 'b-')
plt.plot([D[0], A[0]], [D[1], A[1]], 'b-')
# Plot points A, B, C, D, M, N
plt.plot(*A, 'ro')
plt.text(A[0], A[1], 'A', fontsize=12, ha='right')
plt.plot(*B, 'ro')
plt.text(B[0], B[1], 'B', fontsize=12, ha='right')
plt.plot(*C, 'ro')
plt.text(C[0], C[1], 'C', fontsize=12, ha='right')
plt.plot(*D, 'ro')
plt.text(D[0], D[1], 'D', fontsize=12, ha='right')
plt.plot(*M, 'go')
plt.text(M[0], M[1], 'M', fontsize=12, ha='left')
plt.plot(*N, 'mo')
plt.text(N[0], N[1], 'N', fontsize=12, ha='left')
# Set limits and aspect
plt.xlim(-1, 4)
plt.ylim(-1, 3)
plt.gca().set_aspect('equal', adjustable='box')
plt.title('Dreptunghi ABCD cu punctele M si N')
plt.grid()
plt.show()