{"record":{"id":"5f5095e8b905f963","repo":"aosabook/500lines","slug":"not-an-ellipse","errorCode":null,"errorMessage":"Not an ellipse","messagePattern":"Not an ellipse","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"incomplete/rasterizer/rasterizer/ellipse.py","lineNumber":11,"sourceCode":"from shape import Shape\nfrom poly import ConvexPoly\nfrom geometry import Vector, Transform, quadratic, scale, translate, AABox, HalfPlane\nfrom color import Color\nimport sys\n\nclass Ellipse(Shape):\n    def __init__(self, a=1.0, b=1.0, c=0.0, d=0.0, e=0.0, f=-1.0, color=None):\n        Shape.__init__(self, color)\n        if c*c - 4*a*b >= 0:\n            raise Exception(\"Not an ellipse\")\n        self.a = a\n        self.b = b\n        self.c = c\n        self.d = d\n        self.e = e\n        self.f = f\n        self.gradient = Transform(2*a, c, d, c, 2*b, e)\n        self.center = self.gradient.inverse() * Vector(0, 0)\n        y1, y2 = quadratic(b-c*c/4*a, e-c*d/2*a, f-d*d/4*a)\n        x1, x2 = quadratic(a-c*c/4*b, d-c*e/2*b, f-e*e/4*b)\n        self.bound = AABox.from_vectors(Vector(-(d + c*y1)/2*a, y1),\n                                        Vector(-(d + c*y2)/2*a, y2),\n                                        Vector(x1, -(e + c*x1)/2*b),\n                                        Vector(x2, -(e + c*x2)/2*b))\n        if not self.contains(self.center):\n            raise Exception(\"Internal error, center not inside ellipse\")\n    def value(self, p):\n        return self.a*p.x*p.x + self.b*p.y*p.y + self.c*p.x*p.y \\","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/aosabook/500lines/blob/fba689d101eb5600f5c8f4d7fd79912498e950e2/incomplete/rasterizer/rasterizer/ellipse.py#L1-L29","documentation":"Error \"Not an ellipse\" thrown in aosabook/500lines.","triggerScenarios":"Thrown at incomplete/rasterizer/rasterizer/ellipse.py:11 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":"Ellipse(a=1.0, b=2.0, c=0.0)  # c*c - 4*a*b = -8 < 0, a valid ellipse","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fba689d101eb5600f5c8f4d7fd79912498e950e2","analyzedAt":"2026-08-13T06:26:32.792Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}