Circle

class compas.geometry.Circle[source]

Bases: Conic

A circle is a curve defined by a coordinate system and a radius.

The centre of the circle is at the origin of the coordinate system. The z-axis of the coordinate system defines the normal of the circle plane. The parameter domain is normalized with respect to the polar angle. A parameter value of t = 0 corresponds to the point on the circle at angle 0. A parameter value of t = 1 corresponds to the point on the circle at angle 2 * pi. Moving along the circle in the parameter direction corresponds to moving counter-clockwise around the origin of the local coordinate system.

Parameters:
radiusfloat

The radius of the circle.

framecompas.geometry.Frame, optional

The coordinate frame of the circle. The default value is None, in which case the world coordinate system is used.

namestr, optional

The name of the circle.

Examples

Construct a circle in the world XY plane.

>>> from compas.geometry import Frame, Circle
>>> circle = Circle(radius=5, frame=Frame.worldXY())
>>> circle = Circle(radius=5)

Construct a circle such that the Z axis of its frame such that it aligns with a given line.

>>> from compas.geometry import Line, Frame, Plane, Circle
>>> line = Line([0, 0, 0], [1, 1, 1])
>>> plane = Plane(line.end, line.direction)
>>> circle = Circle.from_plane_and_radius(plane, 5)
>>> circle = Circle(radius=5, frame=Frame.from_plane(plane))

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

>>> from compas_viewer import Viewer  
>>> viewer = Viewer()                    
>>> viewer.scene.add(line)                  
>>> viewer.scene.add(circle)                
>>> viewer.scene.add(circle.frame)          
>>> viewer.show()                      
Attributes:
framecompas.geometry.Frame

The coordinate frame of the circle.

transformationTransformation, read-only

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

centercompas.geometry.Point

The center of the circle.

radiusfloat

The radius of the circle.

diameterfloat, read-only

The diameter of the circle.

areafloat, read-only

The area of the circle.

circumferencefloat, read-only

The circumference of the circle.

eccentricityfloat, read-only

The eccentricity of the circle is zero.

is_closedbool, read-only

True.

is_periodicbool, read-only

True.

Methods

closest_point

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

contains_point

Verify that the circle contains a given point.

from_plane_and_radius

Construct a circle from a plane and a radius.

from_point_and_radius

Construct a circle from a point and a radius.

from_points

Construct a circle from a list of at least three points.

from_three_points

Construct a circle from three points.

normal_at

Construct a normal on the circle at a specific parameter.

point_at

Construct a point on the circle at a specific parameter.

tangent_at

Construct a tangent on the circle at a specific parameter.

Inherited Methods

ToString

Converts the instance to a string.

aabb

Compute the axis-aligned bounding box of the curve.

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.