Sphere

class compas.geometry.Sphere(point, radius, **kwargs)[source]

Bases: Shape

A sphere is defined by a point and a radius.

Parameters
  • point ([float, float, float] | compas.geometry.Point) – The center of the sphere.

  • radius (float) – The radius of the sphere.

Attributes
  • point (compas.geometry.Point) – The center of the sphere.

  • radius (float) – The radius of the sphere.

  • center (compas.geometry.Point, read-only) – The center of the sphere.

  • area (float, read-only) – The surface area of the sphere.

  • volume (float, read-only) – The volume of the sphere.

Examples

>>> from compas.geometry import Point
>>> from compas.geometry import Sphere
>>> sphere1 = Sphere(Point(1, 1, 1), 5)
>>> sphere2 = Sphere((2, 4, 1), 2)
>>> sphere3 = Sphere([2, 4, 1], 2)
>>> from compas.geometry import Point
>>> from compas.geometry import Sphere
>>> sphere = Sphere(Point(1, 1, 1), 5)
>>> sdict = {'point': [1., 1., 1.], 'radius': 5.}
>>> sdict == sphere.data
True

Methods

from_data

Construct a sphere from its data representation.

to_vertices_and_faces

Returns a list of vertices and faces

transform

Transform the sphere.

Inherited Methods

copy

Make an independent copy of the data object.

from_json

Construct an object from serialized data contained in a JSON file.

from_jsonstring

Construct an object from serialized data contained in a JSON string.

to_data

Convert an object to its native data representation.

to_json

Serialize the data representation of an object to a JSON file.

to_jsonstring

Serialize the data representation of an object to a JSON string.

transformed

Returns a transformed copy of this geometry.

validate_data

Validate the object's data against its data schema.

validate_json

Validate the object's data against its json schema.