Setup¶

In [1]:
import math
from math import pi
from math import cos as cos
from math import sin as sin
from math import sqrt as mS
import matplotlib
from matplotlib.patches import Circle as mpC
from matplotlib.patches import Rectangle as mpR
import matplotlib.pyplot as plt
import numpy as np

Constants & Functions¶

In [2]:
colors = ["#C7433FFF",
          "#EBB6B6FF"]

k = 1/2 - 1/mS(8)



#Clear axes.
def clearAx(ax):
    ax.spines["top"].set_visible(False)
    ax.spines["right"].set_visible(False)
    ax.spines["bottom"].set_visible(False)
    ax.spines["left"].set_visible(False)
    ax.set_xticks([])
    ax.set_yticks([])
    return(ax)



#Smallest circle.
def drawBorder(xy, r) :
    return(mpC(xy = xy,
               radius = r,
               edgecolor = 'k',
               facecolor = 'w',
               lw = 4,
               zorder = 1))



#Semicircle of heart.
def drawSemi(xy) :
    return(mpC(xy = xy,
               radius = 0.5,
               edgecolor = colors[0],
               facecolor = colors[1],
               lw = 4,
               zorder = 2))
    
    
    
#Square body of heart.    
def drawSquare(xy) :
    return(mpR(xy = xy,
               height = 1,
               width = 1,
               edgecolor = colors[0],
               facecolor = colors[1],
               angle = 45,
               rotation_point = 'center',
               lw = 4,
               zorder = 3))



#Entire heart from bottom left corner of square and inversion boolean.
def drawHeart(ax, x, y, i) :

    #Rightside up.
    if i == False :
        ax.add_patch(drawSquare((x, y)))
        ax.add_patch(drawSemi((x+k, y+k+1/mS(2))))
        ax.add_patch(drawSemi((x+k+1/mS(2), y+k+1/mS(2))))
        
    #Upside Down.
    else :
        ax.add_patch(drawSquare((x, y)))
        ax.add_patch(drawSemi((x+k, y+k)))
        ax.add_patch(drawSemi((x+k+1/mS(2), y+k)))

Fiddler¶

In [3]:
#Visual!
def heartPic(o, lim) :
    fig = plt.figure(figsize = (8, 8))  
    ax = fig.add_subplot(xlim = (-lim, lim),
                         ylim = (-lim, lim))
    fig.subplots_adjust(left = 0.02, bottom = 0.02, right = 0.98, top = 0.98)
    
    k = 1/2 - 1/mS(8)
    
    #Remove axes and ticks.
    ax = clearAx(ax)

    if o == 'Fiddler' :
        
        t = 1 / (3 - mS(2))      
        r = mS(2) * t
        c1 = 1/mS(2) 
        c2 = c1/2
        cy = r-c1
        k = 2*r / mS(8*t**2-12*t+5)
        ctx = k*c2
        cty = k*(c2-cy)+cy
        
        ax.add_patch(drawBorder((0, cy), r))
        drawHeart(ax, -0.5, -0.5, False)
        
        #TCWUXC.
        ax.plot([-ctx, 0, 0, -c1, 0, 0],
                [cty, cy, -c1, 0, c1, cy],
                color = 'k', lw = 3, ls = ':', zorder = 4)
        #VW.
        ax.plot([-c2, 0],
                [c2, -c1,],
                color = 'k', lw = 3, ls = ':', zorder = 3)
        
        points = [
            #Points
            (" C", (0, cy), 30, 'left', 'center'),
            ("T", (-ctx, cty), 30, 'right', 'bottom'),
            ("U ", (-c1, 0), 30, 'right', 'center'),
            ("V", (-c2, c2), 30, 'center', 'bottom'),
            ("W", (0, c1), 30, 'center', 'bottom'),
            ("X", (0, -c1), 30, 'center', 'top')
                 ]
             
        text = points + [
            #Distances
            ("1/2", ((-c2-ctx)/2, (c2+cty)/2), 16, 'left', 'bottom'),
            ("1/2", ((-c1-c2)/2, c2/2), 16, 'right', 'bottom'),
            ("1/2", (-c2/2, (c1+c2)/2), 16, 'center', 'bottom'),
            ("1 ", (-c1/2, -c1/2), 16, 'right', 'top'),
            ("√5/2", (-c2/2, (-c1+c2)/2), 16, 'right', 'top'),
            (" r-1/2", (-c2/2, (cy+c2+0.06)/2), 16, 'center', 'bottom'),
            (" r", (0, (cy-c1)/2), 16, 'left', 'center'),
            (" √2-r", (0, (cy+c1)/2), 16, 'left', 'center'),
                        ]

    elif o == 'EC1' :
        
        q = (26-7*mS(2))/2 * mS(1 / (102-28*mS(2)))
        r = q + 1/2
        ax.add_patch(drawBorder((0, 0), r))

        x1 = -1/2
        y1 = -r+1/mS(2)-1/2
        drawHeart(ax, x1, y1, False)
        
        x2 = -1/2
        y2 = y1+mS(2)
        drawHeart(ax, x2, y2, False)
       
        x3 = x2+k
        y3 = y2+k+1/mS(2)
        x4 = (x2+k)*(q+1/2) / q
        y4 = (y2+k+1/mS(2))*(q+1/2) / q
               
        #TCZUVY.
        ax.plot([x4, 0, -x3, x3, 0, 0],
                [y4, 0, y3, y3, y3+1/mS(8), -r],
                color = 'k', lw = 3, ls = ':', zorder = 4)
       

        points = [
            #Points
            (" C", (0, 0), 30, 'left', 'bottom'),
            ("T ", (x4, y4), 30, 'right', 'center'),
            ("U ", (x3, y3), 30, 'right', 'center'),
            (" V", (0, y3+1/mS(8)), 30, 'left', 'center'),
            (" W", (0, y3), 30, 'left', 'center'),
            (" X", (0, -r+mS(2)), 30, 'left', 'center'),
            (" Y", (0, -r), 30, 'left', 'center'),
            (" Z", (-x3, y3), 30, 'left', 'center')
                 ]
        text = points
                
        
    elif o == 'EC2' :

        r = mS(22+6*mS(7)) / 4
        ax.add_patch(drawBorder((0, 0), r))
        
        x1 = 1/mS(32) 
        y1 = (6+mS(7)) / mS(32)
        x2 = x1 - 1/2
        y2 = -mS(7)*x1 - 1/mS(8) - 1/2
        drawHeart(ax, x2, y2, False)

        x3 = -x1 - 1/2
        y3 = mS(7)*x1 + 1/mS(8) - 1/2
        drawHeart(ax, x3, y3, True)        

        y4 = mS(7)*x1
        
        #SCTUVZ.
        ax.plot([-x1, 0, -x1, -x1, x1, x1],
                [y1, 0, 0, -y4, y4, -y1],
                color = 'k', lw = 3, ls = ':', zorder = 4)
        #CW.
        ax.plot([0, x1],
                [0, 0],
                color = 'k', lw = 3, ls = ':', zorder = 4)
        #XUY.
        ax.plot([x1, -x1, x1],
                [-y1+mS(2), -y4, -y4],
                color = 'k', lw = 3, ls = ':', zorder = 4)
        
        
        points = [
            #Points
            ("C", (0, 0), 30, 'left', 'top'),
            ("S ", (-x1, y1), 30, 'right', 'center'),
            ("T", (-x1, 0), 30, 'right', 'bottom'),
            ("U ", (-x1, -y4), 30, 'right', 'center'),
            (" V", (x1, y4), 30, 'left', 'center'),
            (" W", (x1, 0), 30, 'left', 'center'),
            (" X", (x1, -y1+mS(2)), 30, 'left', 'center'),
            (" Y", (x1, -y4), 30, 'left', 'center'),
            (" Z", (x1, -y1), 30, 'left', 'center')
                 ]  
        text = points
    
    elif o == 'EC3' :
        
        r = 1.5
        ax.add_patch(drawBorder((0, 0), r))

        x1 = -k
        y1 = x1
        drawHeart(ax, x1, y1, False)
        
        x2 = x1-1/mS(2)
        y2 = x2
        drawHeart(ax, x2, y2, True)
        
        j = 3/mS(8)
        ax.plot([-j, j],
                [-j, j],
                color = 'k', lw = 3, ls = ':', zorder = 4)
        
        points = [
            #Points
            (" C", (0, 0.05), 30, 'left', 'bottom'),
               ]
        text = points
        
        
    for p in points :
        ax.scatter(p[1][0], p[1][1], color = 'k', s = 40, zorder = 4)
            

    for t in text :
        plt.annotate(text = t[0],
                     xy = t[1],
                     c = 'k',
                     size = t[2],
                     ha = t[3],
                     va = t[4],
                     zorder = 4)

    fig.savefig("2025.02.14" + o + ".png", bbox_inches = "tight")
In [4]:
heartPic("Fiddler", 1.11)
In [5]:
heartPic("EC1", 1.6)
In [6]:
heartPic("EC2", 1.6)
In [7]:
heartPic("EC3", 1.6)
Rohan Lewis¶

2025.02.17¶