desde matplotlib importa pyplot como plt
de animación de importación matplotlib
desde matplotlib.patches import Arc
de las matemáticas import pi, sin
roboWidth = float (input (“ancho del Robot \ n:”))
driveDistance = float (input (“distancia del objetivo \ n:”))
#theta = float (input (“ángulo de giro (en términos de pi) \ n:”))
fig = plt.figure ()
- Sistemas distribuidos: ¿El resultado de imposibilidad de FLP y el teorema de CAP de Brewer son básicamente equivalentes?
- Alguien me dijo que me especializara en un dominio CS para evitar quedar desempleado cuando envejeciera, ¿es cierto?
- Cómo aprender sobre qué pueden hacer las matemáticas en una computadora
- ¿Cómo juegan las matemáticas un papel importante en la programación?
- ¿Cómo pruebo o refuto lo siguiente: f (n) = o (g (x)) implica f (n) = O (g (n))?
ax = plt.axes (xlim = (-10,10), ylim = (-10,10))
leftPath = Arc ([0,0], 0,0,0,0,0, color = ‘verde’, ancho de línea = .5, animado = Verdadero)
rightPath = Arc ([0,0], 0,0,0,0,0, color = ‘rojo’, ancho de línea = .5, animado = Verdadero)
def animate (i):
# ————– obtiene variables definidas globalmente ——–
impulso globalDistancia
roboWidth global
# ———- establece variables preliminares —————-
degTheta = i + 1 # <——- evita la división por cero
miniRadius = (driveDistance / 2) / (sin (degTheta * pi / 180))
roboCenter = -1 * (miniRadius)
leftRadius = miniRadius – roboWidth / 2
rightRadius = miniRadius + roboWidth / 2
# ——— establece los atributos de los arcos —————
leftPath.xy = [roboCenter, 0]
leftPath.width = leftRadius * 2
leftPath.height = leftRadius * 2
leftPath.angle = degTheta
leftPath.xy = [roboCenter, 0]
leftPath.width = rightRadius * 2
leftPath.height = rightRadius * 2
leftPath.angle = degTheta
ax.add_patch (leftPath)
ax.add_patch (rightPath)
anim = animation.FuncAnimation (fig, animar, cuadros = 360, intervalo = 20)
plt.show ()