Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to ask how to Simulate a rotating equal triangle with sides L inside a circle of radius r by using python.

I wanted to display the animation.

Here is my code:

Python
import numpy as np
from matplotlib import pyplot as plt
from IPython import display

r=1.0
θa=-20; θb=70 ; θc=160
xa=r*np.cos(θa)
ya=r*np.sin(θa)
xb=r*np.cos(θb)
yb=r*np.sin(θb)
xc=r*np.cos(θc)
yc=r*np.sin(θc)

line_abx = [xa,xb]
line_aby = [ya,yb]
line_bcx = [xb,xc]
line_bcy = [yb,yc]
line_cax = [xc,xa]
line_cay = [yc,ya]

T=2*np.pi/5
tarr=np.linspace(0,10*T,150)

theta = np.linspace(0,10*T,150)
radius = 1.0
a = radius*np.cos(theta)
b = radius*np.sin(theta)

figure , axes = plt.subplots()
axes.plot(a,b,c='red')
axes.set_aspect(1)

plt.plot(0 , 0, '.')
plt.plot(xa ,ya, 'o')
plt.plot(xb ,yb, 'o')
plt.plot(xc ,yc, 'o')
plt.plot(line_abx , line_aby)
plt.plot(line_bcx , line_bcy)
plt.plot(line_cax , line_cay)
plt.show()





- can you spot the problem.Because I want to display the animation

What I have tried:

yes , I have tried it so many times , but it is not display as I wanted.
Posted
Updated 30-Jun-22 8:46am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900