Setup¶

In [1]:
import math
import matplotlib
from matplotlib.animation import FuncAnimation as FA
from matplotlib.patches import Polygon as mpP
import matplotlib.pyplot as plt
import numpy as np

Constants and Helpers¶

In [2]:
#colors
c = ["#073EA5FF", "#073EA588", "#55C667FF", "#55C66788"]



#Original triangle vertices and sides.
t0 = [(0, 0), (4, 3), (4, 0), (0, 0)]



#Original triangle labels.
text0 = [("a", (3.9, 1.6), c[0], 'right', 'top'),
         ("b", (2.1, 0.1), c[0], 'left', 'bottom'),
         ("c", (2.1, 1.6), c[0], 'left', 'top')]



#New triangle vertices and sides.
add0 = [[t0[1], (8, 0), t0[2]],
        [t0[1], (5, 0), t0[2]],
        [t0[0], (4, -3), t0[2]],      
        [t0[0], (4, -2), t0[2]],
        [t0[0], (4, -7/6), t0[2]],
        [t0[0], (4, 4), t0[1]],
        [t0[1], (5.12, 3.84), t0[2]]]



#New triangle labels.
addtext0 = [[("c", (5.9, 1.6), c[2], 'right', 'top'),
             ("b", (5.9, 0.1), c[2], 'right', 'bottom')],
            [("√(a²+(c-b)²)", (4.55, 1.6), c[2], 'left', 'top'),
             ("c-b", (4.45, 0.1), c[2], 'center', 'bottom')],
            [("a", (3.9, -1.6), c[2], 'right', 'bottom'),
             ("c", (2.1, -1.6), c[2], 'left', 'bottom')],  
            [("√(b²+(c-a)²)", (2, -1), c[2], 'right', 'top'),
             ("c-a", (3.9, -1), c[2], 'right', 'center')],
            [("c²/2a", (2, -7/9), c[2], 'center', 'top'),
             ("c²/2a-a", (4.1, -7/12), c[2], 'left', 'center')],            
            [("b√2", (2.2, 2.6), c[2], 'center', 'bottom'),
            ("b-a", (4.1, 3.5), c[2], 'left', 'center')],
           [("2b²/c-c", (4.56, 3.42), c[2], 'right', 'bottom'),
            ("b", (4.55, 2.1), c[2], 'right', 'center')]]



#Triangles.
def triangle(points, ec, fc, ls, lw, closed):
    
    return(mpP(points,
               edgecolor = ec,
               facecolor = fc,
               ls = ls,
               lw = lw,
               closed = closed))



#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)
In [3]:
def appendRight(o) :
    fig = plt.figure(figsize = (11, 7))
    ax = fig.add_subplot(xlim = (-2.02, 9.09),
                         ylim = (-3.03, 4.04))

    ax = clearAx(ax)

    ax.add_patch(triangle(t0, c[1], c[1], "-", 2, True))
    
    ax.add_patch(triangle(add0[o], c[2], c[3], "-", 4, False))
        
    for t in (text0+addtext0[o]) :
        plt.annotate(text = t[0],
                     xy = t[1],
                     c = t[2],
                     size = 30,
                     ha = t[3],
                     va = t[4])
        
    fig.savefig("2024.09.06-" + str(o) + ".png", bbox_inches = 'tight')    

for o in range(7):
    appendRight(o)

Rohan Lewis¶

2024.09.06¶