File:Tautochrone balls full oscillation.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Tautochrone_balls_full_oscillation.gif (640 × 224 pixels, file size: 278 KB, MIME type: image/gif, looped, 50 frames, 2.5 s)
File information
Structured data
Captions
Summary
[edit]DescriptionTautochrone balls full oscillation.gif |
English: Animation of four balls rolling up and down a tautochrone curve. The cycloid shape of the curve lets each ball take the same time for an oscillation, no matter where it starts rolling. For the applied formulas, see the source code below. |
Date | |
Source | Own work |
Author | Geek3 |
Other versions | Tautochrone curve.gif |
GIF development InfoField | This plot was created with Matplotlib. |
Source code InfoField | Python code#!/usr/bin/python
# -*- coding: utf8 -*-
'''
animation of balls on a tautochrone curve
'''
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib import animation # https://matplotlib.org/api/animation_api.html
from math import *
# settings
fname = 'Tautochrone_balls_full_oscillation'
width, height = 640, 224
nframes = 50
fps=20
balls = [
{'a':1.0, 'color':'#0000c0'},
{'a':0.8, 'color':'#c00000'},
{'a':0.6, 'color':'#00c000'},
{'a':0.4, 'color':'#c0c000'}]
def curve(phi):
x = phi + sin(phi)
y = 1.0 - cos(phi)
return np.array([x, y])
def animate(nframe, empty=False):
t = nframe / float(nframes)
# prepare a clean and image-filling canvas for each frame
fig = plt.gcf()
fig.clf()
ax_canvas = plt.gca()
ax_canvas.set_position((0, 0, 1, 1))
ax_canvas.set_xlim(0, width)
ax_canvas.set_ylim(0, height)
ax_canvas.axis('off')
# draw the ramp
x0, y0 = width//2, 18
h = 192
npoints = 400
points = []
for i in range(npoints):
phi = i / (npoints - 1.0) * 2 * pi - pi
x, y = h/2. * curve(phi) + np.array([x0, y0])
points.append([x, y])
rampline = patches.Polygon(points, closed=False, facecolor='none',
edgecolor='black', linewidth=4, capstyle='butt')
points += [[x0+h*pi/2, y0], [x0-h*pi/2, y0], [x0-h*pi/2, y0+h]]
ramp = patches.Polygon(points, closed=True, facecolor='#c0c0c0', edgecolor='none')
ax_canvas.add_patch(ramp)
ax_canvas.add_patch(rampline)
for b in balls:
phi_pendulum = b['a'] * -cos(t * 2 * pi)
phi_wheel = 2 * asin(phi_pendulum)
x, y = h/2. * curve(phi_wheel) + np.array([x0, y0])
ax_canvas.add_patch(patches.Circle((x, y), radius=10.,
facecolor=b['color'], edgecolor='black'))
fig = plt.figure(figsize=(width/100., height/100.))
anim = animation.FuncAnimation(fig, animate, frames=nframes)
print 'saving', fname + '.gif'
anim.save(fname + '.gif', writer='imagemagick', fps=fps)
|
Licensing
[edit]I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 12:49, 7 April 2018 | 640 × 224 (278 KB) | Geek3 (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following page uses this file: