sorbetto.geometry.conic module
- class sorbetto.geometry.conic.Conic(a, b, c, d, e, f, name: str | None = None)[source]
Bases:
AbstractGeometricObject2DThis class is used to represent conic sections. \(a x^2 + b x y + c y^2 + d x + e y + f = 0\) See https://en.wikipedia.org/wiki/Conic_section
- property a: float
The coefficient \(a\) that multiplies \(x^2 y^0\) in the equation of the conic section.
- Returns:
The paramater \(a\) of the conic section.
- Return type:
float
- property b: float
The coefficient \(b\) that multiplies \(x^1 y^1\) in the equation of the conic section.
- Returns:
The paramater \(b\) of the conic section.
- Return type:
float
- property c: float
The coefficient \(c\) that multiplies \(x^0 y^2\) in the equation of the conic section.
- Returns:
The paramater \(c\) of the conic section.
- Return type:
float
- classify(tol: float = 1e-08) str[source]
Classify the conic section.
- Parameters:
tol (float, optional) – the numerical tolerance, positive. Defaults to 1e-8.
- Returns:
a name, in english, for the conic section type
- Return type:
str
- property d: float
The coefficient \(d\) that multiplies \(x^1 y^0\) in the equation of the conic section.
- Returns:
The paramater \(d\) of the conic section.
- Return type:
float
- draw(fig: Figure, ax: Axes, extent, **plt_kwargs)[source]
Draws the part of the conic section that is within some axis-aligned box in some given Pyplot axes.
- Parameters:
fig (_type_) – a Pyplot Figure object
ax (_type_) – a Pyplot Axes object
extent (_type_) – the axis-aligned box \((x_{min}, x_{max}, y_{min}, y_{max})\)
plt_kwargs – options for Pyplot’s plot command.
- property e: float
The coefficient \(e\) that multiplies \(x^0 y^1\) in the equation of the conic section.
- Returns:
The paramater \(e\) of the conic section.
- Return type:
float
- property f: float
The coefficient \(a\) that multiplies \(x^0 y^0\) in the equation of the conic section.
- Returns:
The paramater \(f\) of the conic section.
- Return type:
float
- getLargestX(y)[source]
Computes the largest value of \(x\), for any given \(y\).
- Parameters:
y (_type_) – \(y\)
- Returns:
the largest value of \(x\), for the given \(y\).
- Return type:
_type_
- getLargestY(x)[source]
Computes the largest value of \(y\), for any given \(x\).
- Parameters:
x (_type_) – \(x\)
- Returns:
the largest value of \(y\), for the given \(x\).
- Return type:
_type_
- getMatrixRepresentation() ndarray[source]
Computes the 3 by 3 matrix representation of the conic section. See https://en.wikipedia.org/wiki/Matrix_representation_of_conic_sections
- Returns:
the matrix representation
- Return type:
np.nparray
- getSmallestX(y)[source]
Computes the smallest value of \(x\), for any given \(y\).
- Parameters:
y (_type_) – \(y\)
- Returns:
the smallest value of \(x\), for the given \(y\).
- Return type:
_type_
- getSmallestY(x)[source]
Computes the smallest value of \(y\), for any given \(x\).
- Parameters:
x (_type_) – \(x\)
- Returns:
the smallest value of \(y\), for the given \(x\).
- Return type:
_type_
- isCircle(tol: float = 1e-08) bool[source]
Test if the conic section is a circle.
- Parameters:
tol (float, optional) – the numerical tolerance, positive. Defaults to 1e-8.
- Returns:
True if the conic section is a circle; False otherwise
- Return type:
bool
- isDegenerate(tol: float = 1e-08) bool[source]
See https://en.wikipedia.org/wiki/Degenerate_conic
- Parameters:
tol (float, optional) – the numerical tolerance, positive. Defaults to 1e-8.
- Returns:
True if the conic section is degenerate; False otherwise
- Return type:
bool
- isEllipse(tol: float = 1e-08) bool[source]
Test if the conic section is an ellipse.
- Parameters:
tol (float, optional) – the numerical tolerance, positive. Defaults to 1e-8.
- Returns:
True if the conic section is an ellipse; False otherwise
- Return type:
bool
- isHyperbola(tol: float = 1e-08) bool[source]
Test if the conic section is a hyperbola.
- Parameters:
tol (float, optional) – the numerical tolerance, positive. Defaults to 1e-8.
- Returns:
True if the conic section is a hyperbola; False otherwise
- Return type:
bool