Spheres and circles

A Sphere of dimension \(k\) is initialized by its center, radius and an (optional) \(k+1\) dimensional Subspace.

Spheres can be defined in any dimension and in any Cayley-Klein geometry. If neither a subspace nor a geometry is given at initialization, we get by default a hypersphere in Euclidean geometry.

Since we consider spheres to be lying in \(\mathbb{K}\mathrm P^n\), our points are always given in homogeneous coordinates.

>>> import ddg
>>> import numpy as np
>>> from ddg.geometry.spheres import Sphere

>>> center = np.array([0.0, 4.0, 2.0, 0.0, 8.0])
>>> sphere = Sphere(center, 10.0)

>>> print(sphere)
Hypersphere in 4D Euclidean Geometry
Center: [0. 4. 2. 0. 8.],
Radius: 10.0.

>>> sphere.dimension
3

After initialization, the geometry of sphere can be changed to any CayleyKleinGeometry using method set_geometry

>>> sphere.set_geometry("hyperbolic")

>>> print(sphere)
Hypersphere in 4D Hyperbolic Geometry
Center: [0. 4. 2. 0. 8.],
Radius: 10.0.

Here is another example where we initialize a Circle in \(\mathbb{R}\mathrm P^4\)

>>> P1 = np.array([12.0, 0.0, 1.0, 0.0, 9.0])
>>> P2 = np.array([0.0, 23.0, 0.0, 0.0, 1.0])
>>> P3 = np.array([1.0, 5.0, 4.0, 7.0, 21.0])
>>> center = P1 - P3
>>> circle = Sphere(center, 10.0, subspace=[P1, P2, P3])

>>> print(circle)
Circle in 4D Euclidean Geometry
Center: [ 11.  -5.  -3.  -7. -12.],
Radius: 10.0,
Subspace coordinates:
  [[12.  0.  1.]
   [ 0. 23.  5.]
   [ 1.  0.  4.]
   [ 0.  0.  7.]
   [ 9.  1. 21.]]

>>> circle.dimension
1

Visualization in Blender

A guide on how to visualize ddg objects, including spheres can be found here .