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 vectors).
- Parameters:
- sizeint or tuple of ints (default=None)
size of sample of complex numbers or shape of numpy.ndarray
- seedint (default=None)
seed for obtaining a deterministic function
- Returns:
- complex or numpy.ndarray of numpy.complex128
Notes
Real and imaginary part are standard normally distributed
- ddg.math.complex.to_array(z)[source]
Convert complex numbers to 2D arrays of real and imaginary part.
- Parameters:
- zcomplex
- Returns:
- numpy.ndarray of shape (2,)
- ddg.math.complex.to_complex(x)[source]
Convert 2D array to complex number.
- Parameters:
- xsequence of length 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]
For two complex numbers get scalar product of corresponding elements in R^2.
- Parameters:
- z1,z2complex
- Returns:
- float
- ddg.math.complex.determinant(z1, z2)[source]
For two complex numbers get determinant of matrix of corresponding elements in R^2.
- Parameters:
- z1,z2complex
- Returns:
- float
- 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