ddg.math.complex module

Utility functions for complex analysis of plane geometry. Uses and generates (numpy) complex numbers.

ddg.math.complex.complex_sample(size=None, seed=None)[source]

Get a sample of random complex numbers or numpy.ndarray.

Parameters:
sizearray_like of ints (default=None)

Shape of numpy.ndarray. If size=None then a single complex will be returned.

seedint (default=None)

Seed for obtaining a deterministic function.

Returns:
complex or numpy.ndarray of numpy.complex128

If size=None then complex will be returned, else numpy.ndarray of shape size.

Notes

Real and imaginary part are standard normally distributed

ddg.math.complex.to_array(z)[source]

Convert a complex number to a numpy.ndarray.

Parameters:
zcomplex
Returns:
numpy.ndarray of shape (2, input_shape)

An array with a shape of (2, input_shape), where input_shape is the shape of the input numpy array. If the input is complex, the shape is (2,).

ddg.math.complex.to_complex(x)[source]

Convert an array_like to a complex number.

Parameters:
xarray_like of length shape (2,)
Returns:
complex
ddg.math.complex.homogeneous(z)[source]

Get complex number in homogeneous coordinates.

z is interpreted as the affine coordinate of an element in CP^1.

Parameters:
zcomplex
Returns:
numpy.ndarray of shape (2,)
ddg.math.complex.scalar_product(z1, z2)[source]

Calculate scalar product of two complex numbers of corresponding elements in R^2.

Also accepts numpy.ndarray as input.

Parameters:
z1,z2complex or numpy.ndarray of dtype numpy.complex128
Returns:
float or numpy.ndarray

Returns a float if inputs are of type complex. Otherwise a numpy.ndarray is returned.

ddg.math.complex.determinant(z1, z2)[source]

For two complex numbers get determinant of matrix of corresponding elements in R^2.

Also accepts numpy.ndarray as input.

Parameters:
z1,z2complex or numpy.ndarray of dtype numpy.complex128
Returns:
float or numpy.ndarray

Returns a float if inputs are of type complex. Otherwise a numpy.ndarray is returned.

ddg.math.complex.rel_angle(z1, z2)[source]

Get angle in [0,2*pi) between complex numbers z1,z2.

Parameters:
z1,z2complex
Returns:
float
ddg.math.complex.cr(z1, z2, z3, z4)[source]

Compute complex cross ratio.

cr(z1,z2,z3,z4) = (z1 - z2)/(z2 - z3) * (z3 - z4)/(z4 - z1)

Parameters:
z1,z2,z3,z4complex
Returns:
complex
ddg.math.complex.fourth_point_from_cross_ratio(z, z1, z2, q)[source]

Get z12 such that cr(z, z1, z12, z2) = q

For a quadrilateral of the form

z2_____z12
 |     |
 |     |
 z_____z1

with given z,z1,z2 and q, compute z12 .

Parameters:
z,z1,z2,qcomplex
Returns:
complex
ddg.math.complex.circumcenter(z1, z2, z3)[source]

Get center of circle through three complex numbers.

Parameters:
z1,z2,z3complex
Returns:
numpy.complex128
ddg.math.complex.circumradius(z1, z2, z3)[source]

Get radius of circle through three complex numbers.

Parameters:
z1,z2,z3complex
Returns:
float
ddg.math.complex.intersect_diags(z1, z2, z3, z4)[source]

For a complex quadrilateral (z1,z2,z3,z4) get the intersection point of the diagonals.

The four complex points are given as an argument in positive cyclic order.

z4-----z3
 |\   /|
 |  x  |
 |/   \|
z1-----z2
Parameters:
z1,z2,z3,z4complex
Returns:
complex
ddg.math.complex.intersect_edges(z1, z2, z3, z4)[source]

For a complex quadrilateral (z1,z2,z3,z4) get the intersection of the two opposite edges (z1,z2) and (z3,z4).

Will return complex infinity if intersection does not exist.

z4-----z3--
 |     |    \
 |     |     x
 |     |    /
z1-----z2--
Parameters:
z1,z2,z3,z4complex
Returns:
complex