Capsule

class compas.geometry.Capsule[source]

Bases: Shape

A capsule is defined by a frame, radius, and height.

The capsule is oriented along the z-axis of the frame. The base point (i.e. the centre of the base circle) is at the origin of the frame. Half of the capsule is above the local XY plane of the frame, the other half below.

Parameters:
radiusfloat

The radius of the capsule.

heightfloat

The height of the capsule along the z-axis of the frame. Half of the capsule is above the XY plane of the frame, the other half below.

framecompas.geometry.Frame, optional

The local coordinate system, or “frame”, of the capsule. Default is None, in which case the world coordinate system is used.

namestr, optional

The name of the shape.

Examples

>>> frame = Frame.worldXY()
>>> capsule = Capsule(frame=frame, radius=0.3, heigth=1.0)
>>> capsule = Capsule(radius=0.3, heigth=1.0)
>>> capsule = Capsule()
Attributes:
areafloat, read-only

The surface area of the capsule.

axiscompas.geometry.Line, read-only

The central axis of the capsule.

basecompas.geometry.Point, read-only

The base point of the capsule. The base point is at the origin of the local coordinate system.

circlecompas.geometry.Circle, read-only

The base circle of the capsule. The center of the circle is at the origin of the local coordinate system.

diameterfloat, read-only

The diameter of the base circle of the capsule.

framecompas.geometry.Frame

The local coordinate system of the capsule. The capsule is oriented along the local z-axis.

heightfloat

The height of the capsule.

planecompas.geometry.Plane, read-only

The plane of the capsule. The base point of the plane is at the origin of the local coordinate system. The normal of the plane is in the direction of the z-axis of the local coordinate system.

radiusfloat

The radius of the base circle of the capsule.

transformationcompas.geometry.Transformation

The transformation of the capsule to global coordinates.

volumefloat, read-only

The volume of the capsule.

Methods

contains_point

Verify if a point is inside the capsule.

contains_points

Verify if a list of points is inside the capsule.

from_circle_and_height

Construct a capsule from a circle and a height.

from_line_and_radius

Construct a capsule from a line and a radius.

scale

Scale the capsule.

to_brep

Returns a BRep representation of the capsule.

to_vertices_and_faces

Returns a list of vertices and faces.

Inherited Methods

ToString

Converts the instance to a string.

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.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

rotate

Rotate the shape.

rotated

Returns a rotated copy of this 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.

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_polyhedron

Convert the shape to a polyhedron.

transform

Transform the shape.

transformed

Returns a transformed copy of this geometry.

translate

Translate the shape.

translated

Returns a translated copy of this geometry.

validate_data

Validate the data against the object's data schema.