TheAlgorithms/Python · error · ValueError

Cannot have a capture radius less than 0

Error message

Cannot have a capture radius less than 0

What it means

Error "Cannot have a capture radius less than 0" thrown in TheAlgorithms/Python.

Source

Thrown at physics/basic_orbital_capture.py:88

    capture_radius: The radius of orbital capture and impact for a central body of
    mass M and a projectile moving towards it with velocity v
        SI units: meters | m
    Returns:
    --------
    >>> capture_area(17209590691)
    9.304455331329126e+20
    >>> capture_area(-1)
    Traceback (most recent call last):
        ...
    ValueError: Cannot have a capture radius less than 0

    Returned SI units:
    ------------------
    meters*meters | m**2
    """

    if capture_radius < 0:
        raise ValueError("Cannot have a capture radius less than 0")
    sigma = pi * pow(capture_radius, 2)
    return round(sigma, 0)


if __name__ == "__main__":
    from doctest import testmod

    testmod()

"""
Derivation:

Let: Mt=target mass, Rt=target radius, v=projectile_velocity,
     r_0=radius of projectile at instant 0 to CM of target
     v_p=v at closest approach,
     r_p=radius from projectile to target CM at closest approach,
     R_capture= radius of impact for projectile with velocity v

View on GitHub (pinned to f5988cc097)

Solutions

  1. Pass a capture radius of 0 or greater.

When it happens

Trigger: Thrown at physics/basic_orbital_capture.py:88 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of TheAlgorithms/Python@f5988cc097 (2026-08-14). Data as JSON: /api/errors/f997993ec71fdfab. Report an issue: GitHub.