### How to tell it's type If `b > a`: This is a `vertical` ellipse. If `a > v`: This is a `horizontal` ellipse. """ __doc__ = doc __all__ = ["__doc__", "Ellipse"] import sympy import json from util import newerror from .point import Point from .line import Line EllipseException = newerror("EllipseException") class Ellipse(): __doc__ = doc def __init__(self, major_axis_1, major_axis_2, focus_point_1, focus_point_2, center): self.major_axis = Line(major_axis_1, major_axis_2) self.focus1 = focus_point_1 self.focus2 = focus_point_2 self.center = center @property def h(self): return self.center.x
`::__init__(A, B, C, D, E, F)` <br/> Create a new ConicSection. <br/> A, B, C, D, E, and F are the same as in the equation. `::discrimiant` <br/> A property, which calulates the discrimiant. <br/> It uses `B^2 - 4AC` `::type` <br/> Get the type of Conic Section. <br/> It uses the table listed above, and return the class for that type of conic section. """ __doc__ = doc from util import newerror ConicSectionException = newerror("ConicSectionException") from parabola import Parabola from hyperbola import Hyperbola from circle import Circle from ellipse import Ellipse class ConicSection(): __doc__ = doc def __init__(self, A, B, C, D, E, F): if (A == 0 and B == 0 and C == 0): raise ConicSectionException("A, B, and C cannot all be 0") self.A = A
"HorizontalVertexParabola" ] import sympy import json from util import newerror from .point import Point def jsoncls(o): if hasattr(o, "json"): return o.json() return o.__dict__ ParabolaException = newerror("ParabolaException") class Parabola(): __doc__ = doc class VertexParabola(Parabola): def __init__(self, a, *, h=None, k=None): if a == 0: raise ParabolaException("'a' must not be 0.") self.a = a self.h = h self.k = k @property
* `p1`: The start point, in the form of a Point, a tuple, or a list * `p2`: The end point, in the same form as `p1` `.length` * Calculates the length of the line """ __doc__ = doc from point import Point from util import newerror __all__ = ["__doc__", "Line", "LineException"] LineException = newerror("LineException") class Line(): __doc__ = doc def __init__(self, p1, p2): for i, p in enumerate([p1, p2]): if type(p) == Point: setattr(self, f"p{i+1}", p) elif type(p) in [tuple, list]: setattr(self, f"p{i+1}", Point(*p)) else: raise LineException("Argument must be a Point, list, or tuple") @property def length(self):