ddg.geometry.euclidean_models module

Euclidean geometry module.

Contains model classes and functions for conversion between the models.

class ddg.geometry.euclidean_models.ProjectiveModel(dimension)[source]

Bases: CayleyKleinGeometry, MetricGeometry

Euclidean geometry.

Model space

The model space is RP^n without the points at infinity.

Representation of objects

Objects are just projective points, subspaces and quadrics not at infinity and Euclidean spheres.

Parameters:
dimensionint
Attributes:
dimensionint
property absolute

The absolute quadric.

This is the dual quadric of the quadric with matrix diag([1,...,1, 0]). As the dual of a degenerate quadric, it is contained in the hyperplane at infinity.

Returns:
Quadric
static d(x, y)[source]

Euclidean distance.

Dehomogenizes and computes the norm of the difference of x and y.

Parameters:
x, yPoint or array_like of shape (dimension+1,)
Returns:
float
angle(subspace1, subspace2)[source]

Euclidean angle.

If both subspaces are points, the angle between them as vectors will be returned, up to pi. Otherwise, the smaller angle between the subspaces will be returned, up to pi/2. Currently only hyperplanes are supported in the latter case.

Parameters:
subspace1, subspace2Subspace
Returns:
float
Raises:
NotImplementedError

If the subspaces have unsupported dimensions.

ellipse_from_foci(f1, f2, a)[source]

Get ellipse in 2D from foci and distance parameter.

The returned ellipse will be the set:

{x : |x - f1| + |x - f2| = 2a}
Parameters:
f1, f2Point
afloat

2 * a must ge greater than the distance between the foci.

Returns:
Quadric
Raises:
ValueError

If 2 * a is not greater than the distance between the foci.

classmethod sphere(center, radius, subspace=None, atol=None, rtol=None)[source]
classmethod sphere_from_affine_point_and_normals(point, radius, normals=None, atol=None, rtol=None)[source]

Create a Euclidean sphere from an affine point and normal directions.

Parameters:
pointarray_like of shape (n,)

Affine coordinate vector in n-dimensional space.

radiusfloat
normalsarray_like of shape (k, n) (default=None)

The rows/elements of normals are vectors in affine coordinates. sphere.subspace will be the affine subspace

orthogonal_complement(span(normals)) + point.

The default is an empty array, i.e. sphere.subspace will be the whole space.

atol, rtolfloat (default=None)

Tolerances for the sphere.

Returns:
sphereSphere

Let k’=dim(span(normals)). Returns a Euclidean (n-k’-1)-sphere contained in the (n-k’)-dimensional projective subspace described above.

static sphere_to_quadric(sphere)[source]

Convert Euclidean sphere to quadric

Parameters:
sphereSphere
Returns:
Quadric
classmethod quadric_to_sphere(quadric, atol=None, rtol=None)[source]

Convert quadric to a Euclidean sphere, if it is one.

Parameters:
quadricQuadric
atol, rtolfloat (default=None)

If None is given, the global defaults are used. See ddg.nonexact for details.

Returns:
Sphere
Raises:
ValueError

If quadric is not a sphere.

property ambient_dimension
cayley_klein_distance(v, w)

Alias for self.absolute.cayley_klein_distance.

cayley_klein_sphere(center, radius, subspace=None, atol=None, rtol=None)

Create a Cayley-Klein sphere.

Parameters:
centerPoint or numpy.ndarray of shape (n+1,)
radiusfloat

Cayley-Klein radius

subspaceSubspace or list of numpy.ndarray of shape (k,) (default=None)
Returns:
CayleyKleinSphere
generalized_cayley_klein_sphere(center, radius, subspace=None, atol=None, rtol=None)

Create a generalized Cayley-Klein sphere.

Parameters:
centerPoint or numpy.ndarray of shape (n+1,)
radiusfloat

Generalized radius

subspaceSubspace or list of numpy.ndarray of shape (k,) (default=None)
Returns:
GeneralizedCayleyKleinSphere
inner_product(v, w)

Alias for self.absolute.inner_product.

class ddg.geometry.euclidean_models.DualProjectiveModel(dimension)[source]

Bases: CayleyKleinGeometry

Dual projective model of Euclidean geometry.

Model space

The model space is RP^n without [0,…,0, 1]. The points in this space can be thought of as hyperplanes in R^n.

Representation of objects

Objects are just projective points, subspaces, quadrics and Cayley-Klein spheres that do not contain the origin.

Parameters:
dimensionint
Attributes:
dimensionint
property absolute

The absolute quadric with matrix diag([1,...,1, 0]).

Returns:
Quadric
angle(subspace1, subspace2)[source]

Euclidean angle.

Computes the angle between the duals of the subspaces.

Parameters:
subspace1, subspace2Subspace
Returns:
float
Raises:
NotImplementedError

If the subspaces have unsupported dimensions.

property ambient_dimension
cayley_klein_distance(v, w)

Alias for self.absolute.cayley_klein_distance.

cayley_klein_sphere(center, radius, subspace=None, atol=None, rtol=None)

Create a Cayley-Klein sphere.

Parameters:
centerPoint or numpy.ndarray of shape (n+1,)
radiusfloat

Cayley-Klein radius

subspaceSubspace or list of numpy.ndarray of shape (k,) (default=None)
Returns:
CayleyKleinSphere
generalized_cayley_klein_sphere(center, radius, subspace=None, atol=None, rtol=None)

Create a generalized Cayley-Klein sphere.

Parameters:
centerPoint or numpy.ndarray of shape (n+1,)
radiusfloat

Generalized radius

subspaceSubspace or list of numpy.ndarray of shape (k,) (default=None)
Returns:
GeneralizedCayleyKleinSphere
inner_product(v, w)

Alias for self.absolute.inner_product.

class ddg.geometry.euclidean_models.MoebiusModel(dimension)[source]

Bases: _ProjectiveSubgeometry

Euclidean geometry as a subgeometry of Möbius geometry.

Model space

The model space is the standard Möbius quadric with matrix diag([1,...,1, -1]) without fixed_point.

Representation of objects

Subspaces and spheres are represented as Möbius spheres, i.e. Quadric objects contained in the Möbius quadric.

Parameters:
dimensionint

Notes

This class supports comparison with ==. Two geometries are equal if and only if they have the same type and dimension.

This class also supports the in operator, which checks whether a point is in the model space of this geometry, i.e. the Möbius quadric.

Attributes:
dimensionint
property fixed_point

Projection point on the Möbius quadric. Used to compute metric.

This is the north pole with representative [0,…,0, 0.5, 0.5].

Returns:
Point
d(v, w)[source]

Euclidean distance in the Möbius model.

Given by

d([x], [y])^2 = (-1/2) * <x, y> / (<x, p>, <y, p>)

where p is self.fixed_point and x and y are points in the Möbius quadric not equal to p.

Parameters:
x, yPoint or array_like of shape (dimension+2,)
Returns:
float
property ambient_dimension
cayley_klein_distance(v, w)

Alias for self.absolute.cayley_klein_distance.

cayley_klein_sphere(center, radius, subspace=None, atol=None, rtol=None)

Create a Cayley-Klein sphere.

Parameters:
centerPoint or numpy.ndarray of shape (n+1,)
radiusfloat

Cayley-Klein radius

subspaceSubspace or list of numpy.ndarray of shape (k,) (default=None)
Returns:
CayleyKleinSphere
generalized_cayley_klein_sphere(center, radius, subspace=None, atol=None, rtol=None)

Create a generalized Cayley-Klein sphere.

Parameters:
centerPoint or numpy.ndarray of shape (n+1,)
radiusfloat

Generalized radius

subspaceSubspace or list of numpy.ndarray of shape (k,) (default=None)
Returns:
GeneralizedCayleyKleinSphere
inner_product(v, w)

Alias for self.absolute.inner_product.

absolute: Quadric

The absolute quadric.

ddg.geometry.euclidean_models.projective_to_moebius(object_, embedded=False)[source]

Alias for moebius_models.euclidean_to_projective()

ddg.geometry.euclidean_models.moebius_to_projective(object_, embedded=False)[source]

Alias for moebius_models.projective_to_euclidean()