aosabook/500lines · error · Exception
Not an ellipse
Error message
Not an ellipse
What it means
Error "Not an ellipse" thrown in aosabook/500lines.
Source
Thrown at incomplete/rasterizer/rasterizer/ellipse.py:11
from shape import Shape
from poly import ConvexPoly
from geometry import Vector, Transform, quadratic, scale, translate, AABox, HalfPlane
from color import Color
import sys
class Ellipse(Shape):
def __init__(self, a=1.0, b=1.0, c=0.0, d=0.0, e=0.0, f=-1.0, color=None):
Shape.__init__(self, color)
if c*c - 4*a*b >= 0:
raise Exception("Not an ellipse")
self.a = a
self.b = b
self.c = c
self.d = d
self.e = e
self.f = f
self.gradient = Transform(2*a, c, d, c, 2*b, e)
self.center = self.gradient.inverse() * Vector(0, 0)
y1, y2 = quadratic(b-c*c/4*a, e-c*d/2*a, f-d*d/4*a)
x1, x2 = quadratic(a-c*c/4*b, d-c*e/2*b, f-e*e/4*b)
self.bound = AABox.from_vectors(Vector(-(d + c*y1)/2*a, y1),
Vector(-(d + c*y2)/2*a, y2),
Vector(x1, -(e + c*x1)/2*b),
Vector(x2, -(e + c*x2)/2*b))
if not self.contains(self.center):
raise Exception("Internal error, center not inside ellipse")
def value(self, p):
return self.a*p.x*p.x + self.b*p.y*p.y + self.c*p.x*p.y \View on GitHub (pinned to fba689d101)
Solutions
- Choose coefficients satisfying the ellipse condition c*c - 4*a*b < 0.
- Check for sign errors in a, b, or c; a and b must have the same sign for an ellipse.
- If you intended a hyperbola or parabola, use a different Shape subclass instead of Ellipse.
Example fix
Ellipse(a=1.0, b=2.0, c=0.0) # c*c - 4*a*b = -8 < 0, a valid ellipse
When it happens
Trigger: Thrown at incomplete/rasterizer/rasterizer/ellipse.py:11 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of aosabook/500lines@fba689d101 (2026-08-13).
Data as JSON: /api/errors/5f5095e8b905f963.
Report an issue: GitHub.