Skip to content

Instantly share code, notes, and snippets.

@slaiyer
Created May 6, 2021 23:47
Show Gist options
  • Save slaiyer/9cc4ec17c8f9c178a873ed61725e77d3 to your computer and use it in GitHub Desktop.
Save slaiyer/9cc4ec17c8f9c178a873ed61725e77d3 to your computer and use it in GitHub Desktop.
Euler's identity
#!/usr/bin/env python3
import math
import numpy
from turtle import *
def euler(unit):
d_r_90 = math.pi / 2
arc_length = math.pi * unit
unit_inv = 1 / unit
penup()
forward(unit)
left(d_r_90)
pendown()
for _ in numpy.linspace(start=0, stop=arc_length, num=math.floor(arc_length)):
forward(1)
left(unit_inv)
left(d_r_90)
for _ in range(unit * 2):
forward(0.5)
if __name__ == '__main__':
bgcolor('black')
hideturtle()
title("Euler's identity")
speed('fastest')
pencolor('green')
width(2)
radians()
euler(100)
exitonclick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment