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:
ddg.geometry.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, subspace2ddg.geometry.Subspace
Returns:
float
Raises:
NotImplementedError

If the subspaces have unsupported dimensions.

moebius()[source]

Corresponding projective model of Moebius geometry.

to_moebius(object_, embedded=False)[source]

Alias for projective_to_moebius()

from_moebius(object_, embedded=False)[source]

Alias for moebius_to_projective()

laguerre()[source]

Corresponding projective model (Blaschke cylinder) of Laguerre geometry.

to_laguerre(object_)[source]

Alias for laguerre_models.euclidean_to_projective()

from_laguerre(object_)[source]

Alias for laguerre_models.projective_to_euclidean()

static angle_bisectors(hyperplane1, hyperplane2)[source]

Create the two angle bisecting hyperplanes of two given hyperplanes. The first entry in the output is the angle bisector that is orientation preserving. The second one is orientation reversing.

Parameters:
hyperplane1ddg.geometry.Subspace
hyperplane2ddg.geometry.Subspace
Returns:
(ddg.geometry.Subspace, ddg.geometry.Subspace)

See also

ddg.geometry.angle_bisector_orientation_preserving
ddg.geometry.angle_bisector_orientation_reversing
static angle_bisector_orientation_preserving(hyperplane1, hyperplane2)[source]

Create the orientation preserving angle bisecting hyperplane of two given hyperplanes. It is orientation preserving in the sense, that reflection in this angle bisector maps one hyperplane to the other with matching orientation.

Parameters:
hyperplane1ddg.geometry.Subspace
hyperplane2ddg.geometry.Subspace
Returns:
ddg.geometry.Subspace
static angle_bisector_orientation_reversing(hyperplane1, hyperplane2)[source]

Create the orientation reversing angle bisecting hyperplane of two given hyperplanes. It is orientation reversing in the sense, that reflection in this angle bisector maps one hyperplane to the other with opposite orientation.

Parameters:
hyperplane1ddg.geometry.Subspace
hyperplane2ddg.geometry.Subspace
Returns:
ddg.geometry.Subspace
static perpendicular_bisector(p1, p2)[source]

Create a hyperplane orthogonal to the join of p1 and p2.

It intersects this line in the midpoint of p1.affine_point and p2.affine_point.

Parameters:
p1: ddg.geometry.Point
p2: ddg.geometry.Point
Returns:
ddg.geometry.Subspace

Hyperplane that is orthogonal to the input line.

static reflect_in_hyperplane(subspace, hyperplane)[source]

Reflects a subspace in a hyperplane.

Parameters:
subspaceddg.geometry.Subspace

Subspace to reflect in the hyperplane.

hyperplaneddg.geometry.Subspace

Hyperplane in n-dimensional ambient space.

Returns:
reflected_hyperplaneddg.geometry.Subspace

The reflected subspace.

Raises:
ValueError

if the reflecor is not a hyperplane, if the hyperplane is at infinity, or if the ambient dimensions don’t match.

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:
ddg.geometry.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]
sphere_through_points(*points)[source]

Find the unique k-sphere through given points.

The sphere might degenerate to subspace.

Generically, n points define an (n-2)-sphere. If n given points are contained in a lower-dimensional sphere, this sphere will be returned.

Parameters:
*pointsiterable with types ddg.geometry.Point or float

The points for which to find the sphere.

The point at infinity can be passed as the floating point representation of positive infinity, e.g., as numpy.inf.

Returns:
SphereLike or Subspace
Raises:
ValueError
  • If the points are not contained in a sphere.

  • If a given point is not an element of the according geometry.

  • If only the point at infinity is given.

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:
sphereddg.geometry.spheres.SphereLike

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

orthogonal_sphere(*spheres)[source]

Find the intersection of all spheres orthogonal to the given spheres.

If the output of this function is a non-degenerate sphere (i.e., sphere with positive radius), then this sphere possesses the following property: Any higher-dimensional sphere containing the former sphere is orthogonal to all spheres given in the input. Thus, it is the orthogonal sphere of minimal dimension, if it is unique.

For example, m non-intersecting hyperspheres in general position in n-dimensional Euclidean space have a unique orthogonal (m-2)-sphere, which is returned by this function.

Subspaces can also be inserted or returned.

Returns None if the intersection is empty (including the case when there is no orthogonal spheres).

Parameters:
*spheres: iterable of type `ddg.geometry.spheres.SphereLike` or
`ddg.geometry.Subspace`
Returns:
ddg.geometry.spheres.SphereLike or ddg.geometry.Subspace or None
static radical_subspace(*spheres)[source]

Find the subspace spanned by the centers of all hyperspheres orthogonal to given spheres, or the radical center of given spheres.

For two circles in Euclidean plane the result is usually called the radical line. More generally, for two hyperspheres in Euclidean space the returned subspace is called the radical hyperplane.

Consider two spheres. * If the spheres do not have common points, the radical subspace is the subspace consisting of the centers of all hyperspheres orthogonal to two given spheres. * If the spheres touch, the radical subspace is the common touching subspace. * If the spheres intersect, the radical subspace the subspace spanned by their common sphere.

The radical subspace of more than two spheres is the intersection of their pairs’ radical subspaces.

A point on the radical subspace outside all given spheres represents the center of a common orthogonal Euclidean hypersphere. If the dimension of the radical subspace is non-zero, then such hyperspheres exist. If the dimension is zero, then the point is called the radical center.

Parameters:
*spheres: iterable of type `ddg.geometry.spheres.SphereLike` or
`ddg.geometry.Subspace`
Returns:
ddg.geometry.Subspace or None
static sphere_to_quadric(sphere)[source]

Convert Euclidean sphere to quadric

Parameters:
sphereddg.geometry.spheres.SphereLike
Returns:
ddg.geometry.Quadric
classmethod quadric_to_sphere(quadric, atol=None, rtol=None)[source]

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

Parameters:
quadricddg.geometry.Quadric
atol, rtolfloat (default=None)

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

Returns:
ddg.geometry.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:
centerddg.geometry.Point or numpy.ndarray of shape (n+1,)
radiusfloat

Cayley-Klein radius

subspaceddg.geometry.Subspace or list of numpy.ndarray of shape (k,)
(default=None)
Returns:
ddg.geometry.spheres.CayleyKleinSphere
generalized_cayley_klein_sphere(center, radius, subspace=None, atol=None, rtol=None)

Create a generalized Cayley-Klein sphere.

Parameters:
centerddg.geometry.Point or numpy.ndarray of shape (n+1,)
radiusfloat

Generalized radius

subspaceddg.geometry.Subspace or list of numpy.ndarray of shape (k,)
(default=None)
Returns:
ddg.geometry.spheres.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, subspace2ddg.geometry.Subspace
Returns:
float
Raises:
NotImplementedError

If the subspaces have unsupported dimensions.

laguerre()[source]

Corresponding projective model (Blaschke cylinder) of Laguerre geometry.

to_laguerre(object_, embedded=False)[source]
from_laguerre(object_, embedded=False)[source]
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:
centerddg.geometry.Point or numpy.ndarray of shape (n+1,)
radiusfloat

Cayley-Klein radius

subspaceddg.geometry.Subspace or list of numpy.ndarray of shape (k,)
(default=None)
Returns:
ddg.geometry.spheres.CayleyKleinSphere
generalized_cayley_klein_sphere(center, radius, subspace=None, atol=None, rtol=None)

Create a generalized Cayley-Klein sphere.

Parameters:
centerddg.geometry.Point or numpy.ndarray of shape (n+1,)
radiusfloat

Generalized radius

subspaceddg.geometry.Subspace or list of numpy.ndarray of shape (k,)
(default=None)
Returns:
ddg.geometry.spheres.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:
ddg.geometry.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, yddg.geometry.Point or array_like of shape (dimension+2,)
Returns:
float
property absolute

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

Returns:
ddg.geometry.Quadric
property ambient_dimension
angle(s1, s2)

Angle between two Möbius spheres.

Parameters:
s1, s2ddg.geometry.Quadric

Möbius spheres.

Returns:
float
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:
centerddg.geometry.Point or numpy.ndarray of shape (n+1,)
radiusfloat

Cayley-Klein radius

subspaceddg.geometry.Subspace or list of numpy.ndarray of shape (k,)
(default=None)
Returns:
ddg.geometry.spheres.CayleyKleinSphere
elliptic()

Corresponding projective model of elliptic geometry.

property elliptic_point
property elliptic_subspace
euclidean()

Corresponding projective model of Euclidean geometry.

property euclidean_point
property euclidean_subspace
from_elliptic(object_, embedded=False)

Alias for elliptic_models.projective_to_moebius()

from_euclidean(object_, embedded=False)

Alias for euclidean_models.projective_to_moebius()

from_hyperbolic(object_, embedded=False)

Alias for hyperbolic_models.projective_to_hemisphere()

from_hyperbolic_half_space(object_, embedded=False)

Alias for hyperbolic_models.half_space_to_hemisphere()

from_hyperbolic_poincare(object_, embedded=False)

Alias for hyperbolic_models.poincare_to_projective()

from_lie(object_, embedded=False)
from_paraboloid(object_)

Alias for paraboloid_to_projective_and_back()

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

Create a generalized Cayley-Klein sphere.

Parameters:
centerddg.geometry.Point or numpy.ndarray of shape (n+1,)
radiusfloat

Generalized radius

subspaceddg.geometry.Subspace or list of numpy.ndarray of shape (k,)
(default=None)
Returns:
ddg.geometry.spheres.GeneralizedCayleyKleinSphere
hyperbolic()

Corresponding projective model of hyperbolic geometry.

hyperbolic_half_space()

Corresponding Poincare disk model of hyperbolic geometry.

hyperbolic_poincare()

Corresponding Poincare disk model of hyperbolic geometry.

property hyperbolic_point
property hyperbolic_subspace
inner_product(v, w)

Alias for self.absolute.inner_product.

lie()

Corresponding projective model of Lie geometry.

paraboloid()

Corresponding paraboloid model of Möbius geometry.

pole_of_sphere(sphere)

Return pole corresponding to sphere.

Parameters:
sphereddg.geometry.Quadric
Returns:
ddg.geometry.Subspace
sphere_from_pole(subspace) Quadric

Get a Möbius sphere from its pole.

Returns intersection of Q and Q.polarize(subspace), where Q is the Möbius quadric.

Parameters:
subspaceddg.geometry.Subspace
Returns:
ddg.geometry.Quadric
to_elliptic(object_, embedded=False)

Alias for elliptic_models.moebius_to_projective()

to_euclidean(object_, embedded=False)

Alias for euclidean_models.moebius_to_projective()

to_hyperbolic(object_, embedded=False)

Alias for hyperbolic_models.hemisphere_to_projective()

to_hyperbolic_half_space(object_, embedded=False)

Alias for hyperbolic_models.hemisphere_to_half_space()

to_hyperbolic_poincare(object_, embedded=False)

Alias for hyperbolic_models.projective_to_poincare()

to_lie(object_, embedded=False)
to_paraboloid(object_)

Alias for paraboloid_to_projective_and_back()

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()