mt.geo2d.ellipse
There are many definitions of an ellipse. In our case, an ellipse is an affine transform of the unit circle x^2+y^2=1.
Functions
cast_Ellipse_to_Moments2d()
: Extracts Moments2d from an Ellipse instance.approx_Moments2d_to_Ellipse()
: Approximates a Moments2d instance with a normalised Ellipse that has the same mean and covariance as the mean and covariance of the instance.upper_bound_Ellipse_to_Rect()
: Returns a bounding axis-aligned rectangle of the ellipse.lower_bound_Rect_to_Ellipse()
: Returns an axis-aligned ellipse bounded by the given axis-aligned rectangle x.transform_Aff2d_on_Ellipse()
: Affine-transforms an Ellipse. The resultant Ellipse has affine transformation aff_tfm*obj.aff_tfm.
- mt.geo2d.ellipse.cast_Ellipse_to_Moments2d(obj)
Extracts Moments2d from an Ellipse instance.
- mt.geo2d.ellipse.approx_Moments2d_to_Ellipse(obj)
Approximates a Moments2d instance with a normalised Ellipse that has the same mean and covariance as the mean and covariance of the instance.
- mt.geo2d.ellipse.upper_bound_Ellipse_to_Rect(obj)
Returns a bounding axis-aligned rectangle of the ellipse.
- mt.geo2d.ellipse.lower_bound_Rect_to_Ellipse(x)
Returns an axis-aligned ellipse bounded by the given axis-aligned rectangle x.
- mt.geo2d.ellipse.transform_Aff2d_on_Ellipse(aff_tfm, obj)
Affine-transforms an Ellipse. The resultant Ellipse has affine transformation aff_tfm*obj.aff_tfm.
Classes
Ellipse
: Ellipse, defined as an affine transform the unit circle x^2+y^2=1.
- class mt.geo2d.ellipse.Ellipse(aff_tfm, make_normalised=True)
Ellipse, defined as an affine transform the unit circle x^2+y^2=1.
If the unit circle is parameterised by (cos(t), sin(t)) where t in [0,2pi) then the ellipse is parameterised by f0 + f1 cos(t) + f2 sin(t), where f0 is the bias vector, f1 and f2 are the first and second column of the weight matrix respectively, of the affine transformation. f1 and f2 are called first and second axes of the ellipse.
Note that this representation is not unique, the same ellipse can be represented by an infinite number of affine transforms of the unit circle. To make the representation more useful, we further assert that when f1 and f2 are perpendicular (linearly independent), the ellipse is normalised. In other words, the weight matrix is a unitary matrix multiplied by a diagonal matrix. After normalisation there is only a finite number of ways to represent the same ellipse. You can normalise either at initialisation time, or later by invoking member function normalised.
- Parameters:
aff_tfm (Aff2d) – an affine transformation
make_normalised (bool) – whether or not to adjust the affine transformation to make a normalised representation of the ellipse
Examples
>>> from mt import np, glm, geo2d >>> a = geo2d.Aff2d(offset=np.array([1,2]), linear=glm.vec4(0.3, 7, 0.3, 0.3)) >>> geo2d.Ellipse(a) Ellipse(aff_tfm=Aff2d(offset=vec2( 1, 2 ), linear=mat2x2(( -0.0901656, -7 ), ( -0.29995, 0.0038636 ))))
Notes
Ellipse follows the convention of Ellipsoid closely.
See also
mt.geond.ellipsoid.Ellipsoid
Inheritance
digraph inheritance4588573ff5 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Ellipse" [URL="#mt.geo2d.ellipse.Ellipse",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Ellipse, defined as an affine transform the unit circle x^2+y^2=1."]; "TwoD" -> "Ellipse" [arrowsize=0.5,style="setlinewidth(0.5)"]; "GeometricObject" -> "Ellipse" [arrowsize=0.5,style="setlinewidth(0.5)"]; "GeometricObject" [URL="../mt.geo/mt.geo.object.html#mt.geo.object.GeometricObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A geometric object which lives in a d-dimensional Euclidean space."]; "TwoD" [URL="../mt.geo/mt.geo.object.html#mt.geo.object.TwoD",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin to assert that the geometric object lives in 2D Euclidean space."]; }- __init__(aff_tfm, make_normalised=True)
Initialises an ellipse with an affine transformation.
- __repr__()
Return repr(self).
- property area
The absolute area of the ellipse’s interior.
- property f0
origin
- property f1
first axis
- property f2
second axis
- normalised()
Returns an equivalent ellipse where f1 and f2 are perpendicular (linearly independent).