Skip to content

Instantly share code, notes, and snippets.

@max-kov
Created March 21, 2017 22:45
Show Gist options
  • Save max-kov/f9b0c9952017275b902577c5042f2d97 to your computer and use it in GitHub Desktop.
Save max-kov/f9b0c9952017275b902577c5042f2d97 to your computer and use it in GitHub Desktop.
circle rolling in another circle
import pygame
import numpy as np
# change these values
points = 50000
radius1 = 100.0
radius2 = 70.0
point_disp = 100.0
angle_ratio =radius1/radius2
resolution = np.array([1000, 500])
start_point = [500,250]
angular_speed = 2*radius1*np.pi/points
pygame.init()
window = pygame.display.set_mode(resolution)
def circloid_from_iteration(num):
return np.array([np.cos(num * angular_speed),np.sin(num * angular_speed)])*radius1 + start_point + \
np.array([np.cos(num * angular_speed * angle_ratio),np.sin(num * angular_speed * angle_ratio)])*point_disp
point_coords = np.array([circloid_from_iteration(a) for a in range(points)])
last_point = point_coords[0]
for point in point_coords:
pygame.draw.line(window, (255, 255, 255), last_point, point)
last_point = point
pygame.display.update()
while 1:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment