Results

Distance Formula — Pythagorean on a Grid

Animation coming — full Sora 2 prompt below. Video will replace this placeholder.

Plain English first

You have two points on a grid. You want the straight-line distance between them.

Draw a right triangle. Make the horizontal leg the difference in x-coordinates, and the vertical leg the difference in y-coordinates. The straight-line distance is the hypotenuse of that triangle.

This is the Pythagorean theorem — applied to a coordinate grid. The formula looks complicated but it's just a² + b² = c², solved for c, where a = Δx and b = Δy.


Standard math notation

Distance formula:
  d = √((x₂ − x₁)² + (y₂ − y₁)²)

This is directly the Pythagorean theorem:
  horizontal leg = (x₂ − x₁)
  vertical leg   = (y₂ − y₁)
  hypotenuse     = d

  d² = (x₂−x₁)² + (y₂−y₁)²
  d  = √(above)

Midpoint formula (center of the segment):
  M = ((x₁+x₂)/2,  (y₁+y₂)/2)
  Average the x-coordinates, average the y-coordinates.

Verbose Python with descriptive names

def compute_distance_between_two_points(
    x_of_first_point,
    y_of_first_point,
    x_of_second_point,
    y_of_second_point
):
    """
    Distance = hypotenuse of the right triangle connecting the two points.
    Horizontal leg = difference in x. Vertical leg = difference in y.
    Pythagorean theorem: d² = (Δx)² + (Δy)²  →  d = √(Δx² + Δy²)
    """
    horizontal_distance = x_of_second_point - x_of_first_point
    vertical_distance   = y_of_second_point - y_of_first_point
    sum_of_squares      = horizontal_distance**2 + vertical_distance**2
    straight_line_distance = sum_of_squares ** 0.5   # square root
    return straight_line_distance

def compute_midpoint_between_two_points(
    x_of_first_point,
    y_of_first_point,
    x_of_second_point,
    y_of_second_point
):
    """
    Midpoint is the average of each coordinate separately.
    Halfway in x, halfway in y.
    """
    x_of_midpoint = (x_of_first_point + x_of_second_point) / 2
    y_of_midpoint = (y_of_first_point + y_of_second_point) / 2
    return x_of_midpoint, y_of_midpoint

# Classic 3-4-5 triangle on a grid
distance = compute_distance_between_two_points(
    x_of_first_point=1,
    y_of_first_point=1,
    x_of_second_point=4,
    y_of_second_point=5
)
print(f"Distance: {distance}")   # 5.0 (horizontal=3, vertical=4, hypotenuse=5)

midpoint = compute_midpoint_between_two_points(1, 1, 4, 5)
print(f"Midpoint: {midpoint}")   # (2.5, 3.0)

# 3D distance — same idea, add a third leg
def compute_3d_distance(x1, y1, z1, x2, y2, z2):
    """
    Pythagorean theorem applied twice: once for x+y, once for result+z.
    d = √(Δx² + Δy² + Δz²)
    """
    dx, dy, dz = x2-x1, y2-y1, z2-z1
    return (dx**2 + dy**2 + dz**2) ** 0.5

Sora 2 video prompt

8-second animation. Two points A(1,1) and B(4,5) appear on a coordinate grid.
A horizontal dashed line forms between them labeled 'run = 3'. A vertical
dashed line forms labeled 'rise = 4'. The right triangle is complete and its
sides glow. Squares grow on each leg: 9 and 16. They combine: √25 = 5. The
hypotenuse lights up labeled 'd = 5'. Formula morphs into d = √((x₂-x₁)²+(y₂-y₁)²).
Warm earth tones, clean coordinate grid.

Builds on

See also

Comments

No comments yet. Be the first!


Comments are moderated and will appear after approval.