"""Functions for calculating common geometric measurements.

This module provides functions for calculating areas, volumes, distances,
perimeters, and surface areas of common geometric shapes.

Author: Chris Mayfield
Version: 09/21/2026
"""

import math


def circle_area(radius):
    """Return the area of a circle.

    Args:
        radius (float): The radius of the circle.

    Returns:
        float: The area of the circle.
    """
    return math.pi * radius**2


def rectangle_area(length, width):
    """Return the area of a rectangle.

    Args:
        length (float): The length of the rectangle.
        width (float): The width of the rectangle.

    Returns:
        float: The area of the rectangle.
    """
    return length * width


def triangle_area(base, height):
    """Return the area of a triangle.

    Args:
        base (float): The length of the base.
        height (float): The height of the triangle.

    Returns:
        float: The area of the triangle.
    """
    return 0.5 * base * height


def sphere_volume(radius):
    """Return the volume of a sphere.

    Args:
        radius (float): The radius of the sphere.

    Returns:
        float: The volume of the sphere.
    """
    return (4 / 3) * math.pi * radius**3


def cylinder_volume(radius, height):
    """Return the volume of a cylinder.

    Args:
        radius (float): The radius of the cylinder.
        height (float): The height of the cylinder.

    Returns:
        float: The volume of the cylinder.
    """
    return math.pi * radius**2 * height


def rectangular_prism_volume(length, width, height):
    """Return the volume of a rectangular prism.

    Args:
        length (float): The length of the rectangular prism.
        width (float): The width of the rectangular prism.
        height (float): The height of the rectangular prism.

    Returns:
        float: The volume of the rectangular prism.
    """
    return length * width * height


def distance(x1, y1, x2, y2):
    """Return the distance between two points.

    Args:
        x1 (float): The x-coordinate of the first point.
        y1 (float): The y-coordinate of the first point.
        x2 (float): The x-coordinate of the second point.
        y2 (float): The y-coordinate of the second point.

    Returns:
        float: The distance between the two points.
    """
    return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)


def midpoint(x1, y1, x2, y2):
    """Return the midpoint between two points.

    Args:
        x1 (float): The x-coordinate of the first point.
        y1 (float): The y-coordinate of the first point.
        x2 (float): The x-coordinate of the second point.
        y2 (float): The y-coordinate of the second point.

    Returns:
        tuple[float, float]: The x- and y-coordinates of the midpoint.
    """
    x = (x1 + x2) / 2
    y = (y1 + y2) / 2
    return (x, y)


def right_triangle_hypotenuse(a, b):
    """Return the length of the hypotenuse of a right triangle.

    Args:
        a (float): The length of one leg of the triangle.
        b (float): The length of the other leg of the triangle.

    Returns:
        float: The length of the hypotenuse.
    """
    return math.sqrt(a**2 + b**2)


def rectangle_perimeter(length, width):
    """Return the perimeter of a rectangle.

    Args:
        length (float): The length of the rectangle.
        width (float): The width of the rectangle.

    Returns:
        float: The perimeter of the rectangle.
    """
    return 2 * (length + width)


def sphere_surface_area(radius):
    """Return the surface area of a sphere.

    Args:
        radius (float): The radius of the sphere.

    Returns:
        float: The surface area of the sphere.
    """
    return 4 * math.pi * radius**2


if __name__ == "__main__":
    print("Circle area:", circle_area(5))
    print("Rectangle area:", rectangle_area(4, 6))
    print("Triangle area:", triangle_area(10, 8))
    print("Sphere volume:", sphere_volume(3))
    print("Cylinder volume:", cylinder_volume(3, 5))
    print("Rectangular prism volume:", rectangular_prism_volume(4, 5, 6))
    print("Distance:", distance(1, 2, 4, 6))
    print("Midpoint:", midpoint(1, 2, 5, 8))
    print("Right triangle hypotenuse:", right_triangle_hypotenuse(3, 4))
    print("Rectangle perimeter:", rectangle_perimeter(4, 6))
    print("Sphere surface area:", sphere_surface_area(3))
