Sphere

class compas.geometry.Sphere[source]

Bases: Shape

A sphere is defined by a point and a radius.

Parameters:
radius: float

The radius of the sphere.

frame: :class:`compas.geometry.Frame`, optional

The local coordinates system, or “frame”, of the sphere. Default is None, in which case the sphere is constructed in world coordinates.

point: :class:`compas.geometry.Point`, optional

The center of the sphere. When provided, this point overwrites the location of the origin of the local coordinate system.

namestr, optional

The name of the shape.

Examples

>>> from compas.geometry import Frame
>>> from compas.geometry import Sphere
>>> sphere1 = Sphere(frame=Frame.worldXY(), radius=5)
>>> sphere1 = Sphere(radius=5)
Attributes:
areafloat, read-only

The surface area of the sphere.

axiscompas.geometry.Line, read-only

The central axis of the sphere.

basecompas.geometry.Point, read-only

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

circlecompas.geometry.Circle, read-only

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

diameterfloat, read-only

The diameter of the sphere.

framecompas.geometry.Frame

The coordinate system of the sphere.

planecompas.geometry.Plane, read-only

The plane of the sphere. 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 sphere.

transformationcompas.geometry.Transformation

The transformation of the sphere to global coordinates.

volumefloat, read-only

The volume of the sphere.

Methods

contains_point

Verify if a point is inside the sphere.

contains_points

Verify if a list of points are inside the sphere.

from_point_and_radius

Construct a sphere from a point and a radius.

scale

Scale the sphere.

to_brep

Returns a BRep representation of the sphere.

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.