You are on page 1of 2

19/02/2024, 17:22 me232a2

In [ ]: import numpy as np
import matplotlib.pyplot as plt

# Define parameters
u, v, w = 2.09, 0.33, 1.96
angles_deg = [63.7721, -51.6935, 47.4041]
l = 1.19
d_min, d_max = -32, 10
gx, gy = 0.6075, -0.6909
n = d_max - d_min + 1

# Convert angles to radians


angles_rad = np.deg2rad(angles_deg)

# Calculate theta
theta = np.tile(angles_rad[2], n) + np.deg2rad(np.linspace(start=d_min, s

# Calculate H and K
H = w * np.cos(theta) - gx
K = w * np.sin(theta) - gy

# Calculate sigma and rho


sigma = []
rho = []
for i in range(n):
h = w * np.cos(theta[i]) - gx
k = w * np.sin(theta[i]) - gy
rho_i = np.arcsin((u**2 - h**2 - k**2 - v**2) / (2 * v * np.sqrt(h**2
sigma_i = np.arccos((h + v * np.cos(angles_rad[1])) / u)
rho.append(rho_i)
sigma.append(sigma_i)

# Calculate X and Y
X = w * np.cos(theta) + (v + l) * np.cos(rho)
Y = w * np.sin(theta) + (v + l) * np.sin(rho)

# Plot
plt.plot(X, Y)
plt.title('Path of a Particle')
plt.xlabel('X Position')
plt.ylabel('Y Position')
plt.grid(True)
plt.show()

file:///Users/anubhav/Desktop/Trial/me232a2.html 1/2
19/02/2024, 17:22 me232a2

file:///Users/anubhav/Desktop/Trial/me232a2.html 2/2

You might also like