Question

Plotting trajectories Classical Mechanics (Python) Question: In the plot, set v = 1 m/s, ω =...

Plotting trajectories Classical Mechanics (Python)

Question: In the plot, set v = 1 m/s, ω = 1 1/s, and plot the trajectory for t ∈ [−6π, 6π].

Code:

import numpy as np
import matplotlib.pyplot as plt

tx=[]
for i in range(180):
    tx.append(i)

radianConverter = np.pi/180
x_2 = [1*t*np.cos(2*np.pi*t*radianConverter) for t in tx]
y_2 = [1*t*np.sin(2*np.pi*t*radianConverter) for t in tx]
plt.figure(figsize=[10,10])
plt.grid(True)
plt.axhline(y=0, color='k')
plt.axvline(x=0, color='k')
plt.plot(x_2,y_2)
plt.show()

What changes do I have to do in order to fit the question parameters?

Homework Answers

Answer #1

I have made the required changes as per the question parameters:
1. Since t ∈ [−6π, 6π] so I executed the loop from i = -6*180 to 6*180
2.
ω = 1 1/s, so radianConverter is adjusted, radianConverter = 11* np.pi/180

//MODIFIED PROGRAM IS BELOW

import numpy as np
import matplotlib.pyplot as plt

tx=[]
i = -6*180;
for i in range(6*180):
tx.append(i)

radianConverter = 11* np.pi/180
x_2 = [1*t*np.cos(2*np.pi*t*radianConverter) for t in tx]
y_2 = [1*t*np.sin(2*np.pi*t*radianConverter) for t in tx]
plt.figure(figsize=[10,10])
plt.grid(True)
plt.axhline(y=0, color='k')
plt.axvline(x=0, color='k')
plt.plot(x_2,y_2)
plt.show()

The resultant output figure after modification is:



Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT