Sphere

Added in version 1.2.

class Sphere(*args, **kwargs)

A sphere, represented by its center and radius.

Constructors

class Sphere
classmethod alloc() Sphere

Allocates a new Sphere.

The contents of the newly allocated structure are undefined.

Added in version 1.2.

Methods

class Sphere
contains_point(point: Point3D) bool

Checks whether the given point is contained in the volume of a Sphere.

Added in version 1.2.

Parameters:

point – a Point3D

distance(point: Point3D) float

Computes the distance of the given point from the surface of a Sphere.

Added in version 1.2.

Parameters:

point – a Point3D

equal(b: Sphere) bool

Checks whether two Sphere are equal.

Added in version 1.2.

Parameters:

b – a Sphere

free() None

Frees the resources allocated by alloc().

Added in version 1.2.

get_bounding_box() Box

Computes the bounding box capable of containing the given Sphere.

Added in version 1.2.

get_center() Point3D

Retrieves the coordinates of the center of a Sphere.

Added in version 1.2.

get_radius() float

Retrieves the radius of a Sphere.

Added in version 1.2.

init(center: Point3D | None, radius: float) Sphere

Initializes the given Sphere with the given center and radius.

Added in version 1.2.

Parameters:
  • center – the coordinates of the center of the sphere, or None for a center in (0, 0, 0)

  • radius – the radius of the sphere

init_from_points(points: Sequence[Point3D], center: Point3D | None = None) Sphere

Initializes the given Sphere using the given array of 3D coordinates so that the sphere includes them.

The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all points.

Added in version 1.2.

Parameters:
  • points – an array of Point3D

  • center – the center of the sphere

init_from_vectors(vectors: Sequence[Vec3], center: Point3D | None = None) Sphere

Initializes the given Sphere using the given array of 3D coordinates so that the sphere includes them.

The center of the sphere can either be specified, or will be center of the 3D volume that encompasses all vectors.

Added in version 1.2.

Parameters:
  • vectors – an array of Vec3

  • center – the center of the sphere

is_empty() bool

Checks whether the sphere has a zero radius.

Added in version 1.2.

translate(point: Point3D) Sphere

Translates the center of the given Sphere using the point coordinates as the delta of the translation.

Added in version 1.2.

Parameters:

point – the coordinates of the translation

Fields

class Sphere
center
radius