In [ ]:
def distance(A, B):
'''Taxicab distance between two tuples'''
return abs(A[0]-B[0])+abs(A[1]-B[1])
distance((0,0),(3,5))

In [ ]:
# http://www.ipythonblocks.org/
from ipythonblocks import BlockGrid
import math

In [ ]:
adaYellow=(245,225,52)


In [ ]:
from ipywidgets import interact


An interactive. For playing with the 'eccentricity' $e$

In [ ]:
grid = BlockGrid(31,31,block_size=5,fill=(255,255,255))
# Directrix is col=0
d = 0
# Focus is at row 0, col 1
F = (5,16)
def draw(e):
for block in grid:
distance_from_edge = block.col
distance_from_focus = distance((block.col, block.row), F)
if distance_from_edge == round(e*distance_from_focus):
else:
if block.col == d:
if (block.col, block.row) == F:
return grid
interact(draw, e=(0,3,0.1));


To save a bunch of images

In [ ]:
grid = BlockGrid(31,31,block_size=5,fill=(255,255,255))
# Directrix is col=0
d = 0
# Focus is at row 0, col 1
F = (5,16)
for i in range(0,21,1):
e = i/10
for block in grid:
distance_from_edge = block.col
distance_from_focus = distance((block.col, block.row), F)
if distance_from_focus == round(e*distance_from_edge):