Ellipse

class compas.geometry.Ellipse[source]

Bases: Conic

An ellipse is a curve defined by a coordinate system and a major and minor axis.

The centre of the ellipse is at the origin of the coordinate system. The major axis is parallel to the local x-axis. The minor axis is parallel to the local y-axis. The parameter domain of an ellipse is [0, 2*pi]. Moving along the ellipse in the parameter direction corresponds to moving counter-clockwise around the origin of the local coordinate system.

Parameters:
majorfloat

The major of the ellipse.

minorfloat

The minor of the ellipse.

framecompas.geometry.Frame, optional

The local coordinate system of the ellipse. The default value is None, in which case the ellipse is constructed in the XY plane of the world coordinate system.

namestr, optional

The name of the ellipse.

Examples

Construct an ellipse in the world XY plane.

>>> from compas.geometry import Frame, Ellipse
>>> ellipse = Ellipse(major=3, minor=2, frame=Frame.worldXY())
>>> ellipse = Ellipse(major=3, minor=2)

Construct an ellipse such that its normal aligns with a given line.

>>> from compas.geometry import Line, Frame, Plane, Ellipse
>>> line = Line([0, 0, 0], [1, 1, 1])
>>> plane = Plane(line.end, line.direction)
>>> ellipse = Ellipse.from_plane_major_minor(plane, 3, 2)
>>> ellipse = Ellipse(major=3, minor=2, frame=Frame.from_plane(plane))

Visualise the line, ellipse, and frame of the ellipse with the COMPAS viewer.

>>> from compas_view2.app import App  
>>> viewer = App()                    
>>> viewer.add(line)                  
>>> viewer.add(ellipse)               
>>> viewer.add(ellipse.frame)         
>>> viewer.run()                      
Attributes:
framecompas.geometry.Frame

The coordinate frame of the ellipse.

transformationTransformation, read-only

The transformation from the local coordinate system of the ellipse (frame) to the world coordinate system.

majorfloat

The major of the ellipse.

minorfloat

The minor of the ellipse.

planecompas.geometry.Plane, read-only

The plane of the ellipse.

areafloat, read-only

The area of the ellipse.

circumferencefloat, read-only

The length of the circumference of the ellipse.

semifocalfloat, read-only

The semi-focal distance of the ellipse. This is the distance from the center of the ellipse to the focus points.

focalfloat, read-only

The distance between the two focus points.

eccentricityfloat, read-only

The eccentricity of the ellipse. This is the ratio between the semifocal length to the length of the semi-major axis.

focus1compas.geometry.Point, read-only

The first focus point of the ellipse.

focus2compas.geometry.Point, read-only

The second focus point of the ellipse.

directix1compas.geometry.Line, read-only

The first directix of the ellipse. The directix is perpendicular to the major axis and passes through a point at a distance major **2 / semifocal along the positive xaxis from the center of the ellipse.

directix2compas.geometry.Line, read-only

The second directix of the ellipse. The directix is perpendicular to the major axis and passes through a point at a distance major **2 / semifocal along the negative xaxis from the center of the ellipse.

is_closedbool, read-only

True.

is_periodicbool, read-only

True.

is_circlebool, read-only

True if the ellipse is a circle.

Methods

from_plane_major_minor

Construct a ellipse from a point and major and minor axis lengths.

from_point_major_minor

Construct a ellipse from a point and major and minor axis lengths.

normal_at

Compute the normal at a specific parameter.

point_at

Compute the point at a specific parameter.

tangent_at

Compute the tangent at a specific parameter.

Inherited Methods

ToString

Converts the instance to a string.

aabb

Compute the axis-aligned bounding box of the curve.

closest_point

Compute the closest point on the curve to a given point.

compute_aabb

Compute the axis-aligned bounding box of the geometry.

compute_obb

Compute the oriented bounding box of the geometry.

copy

Make an independent copy of the data object.

curvature_at

Compute the curvature vector of the curve at a parameter.

divide_by_count

Compute the curve parameters that divide the curve into a specific number of equal length segments.

divide_by_length

Compute the curve parameters that divide the curve into segments of specified length.

fair

frame_at

Compute the local frame of the curve at a parameter.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

from_obj

Load a curve from an OBJ file.

from_step

Load a curve from a STP file.

length

Compute the length of the curve.

offset

reverse

Reverse the parametrisation of the curve.

reversed

Reverse a copy of the curve.

rotate

Rotate the geometry.

rotated

Returns a rotated copy of this geometry.

scale

Scale the geometry.

scaled

Returns a scaled copy of this geometry.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

smooth

split

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

to_obj

Write the curve geometry to an OBJ file.

to_points

Convert the curve to a list of points.

to_polygon

Convert the curve to a polygon.

to_polyline

Convert the curve to a polyline.

to_step

Write the curve geometry to a STP file.

transform

Transform the local coordinate system of the curve.

transformed

Returns a transformed copy of this geometry.

translate

Translate the geometry.

translated

Returns a translated copy of this geometry.

trim

validate_data

Validate the data against the object's data schema.