ddg.math.projective module
Utility functions for the projective module.
- ddg.math.projective.homogenize(vector, affine_component=-1)[source]
Homogenize a coordinate vector by inserting a 1.
- Parameters:
- vectornumpy.ndarray of shape (n,)
The vector to be homogenized.
- affine_componentint (default=-1)
Index of inserted 1 in the output vector.
- Returns:
- numpy.ndarray of shape (n+1,)
- ddg.math.projective.dehomogenize(vector, affine_component=-1, atol=None, rtol=None)[source]
Pick an affine representative for a homogenous coordinate vector.
- Parameters:
- vectornumpy.ndarray of shape (n+1,)
The vector to be dehomogenized.
- affine_componentint (default=-1)
Index of affine component normalized to 1 in the output vector.
- Returns:
- numpy.ndarray of shape (n,)
Notes
This function uses the global tolerance defaults if
atolorrtolare set to None. See ddg.abc.NonExact for details.
- ddg.math.projective.in_general_position(points)[source]
Checks whether a list of k+1 points in n-dimensional projective are in general position.
- Parameters:
- pointslist
List of numpy.ndarray of shape (n+1,)
- Returns:
- bool
True if the points are in general position, False otherwise.
- Raises:
- ValueError
If no points are given.
Notes
If k <= n, we test whether their lifts in (n+1)-dimensional space are linearly independent. If k > n, we test whether any (n+1)-subset of them is contained in a hyperplane of n-dimensional projective space.
- ddg.math.projective.is_projective_frame(points)[source]
Checks whether a list of n+2 points in n-dimensional projective space form a projective frame.
- Parameters:
- pointslist
List of numpy.ndarray of shape (n+1,)
- Returns:
- bool
True if the points are a projective frame, False otherwise.
- Raises:
- ValueError
If no points are given.
Notes
A list of n+1 fundamental points and one unit point in projective space are called a projective frame if they are in general position.
- ddg.math.projective.point_of_intersection(planes, homogeneous_coords=True)[source]
Computes the point of intersection of given hyperplanes (in dual coordinates). If more hyperplanes are given than the dimension of the space, a least square solution is computed.
E.g. in RP^3 it computes the intersection of (at least) three given planes.
- Parameters:
- planeslist
List of planes given in dual coordinates, i.e. by a vector of the form (a,-b) for a.T * x - b = 0
- Returns:
- intersectionarray
Intersection of the given planes
- ddg.math.projective.affine_transformation(A, b, affine_component=-1)[source]
Assemble affine transformation.
Given a matrix and a vector
A1 | A2 A = ---|--- A3 | A4 b1 b = -- b2assemble the projective transformation
A1 | b1 | A2 ---|----|---- F = 0 | 1 | 0 <--- i ---|----|---- A3 | b2 | A4 ^ iwhere i is
affine_component. It corresponds in affine coordinates to the affine transformationx -> Ax + b.- Parameters:
- Anumpy.ndarray of shape (n, n)
- bnumpy.ndarray of shape (n,)
- affine_componentint
- Returns:
- Fnumpy.ndarray of shape (n+1, n+1)
- ddg.math.projective.decompose_affine_transformation(F, affine_component=-1, atol=None, rtol=None)[source]
Decompose affine transformation.
Given a projective transformation
A1 | b1 | A2 ---|----|---- F = 0 | s | 0 <--- i ---|----|---- A3 | b2 | A4 ^ iwhere i is
affine_component, disassemble it into a matrix and a vectorA1 | A2 A = 1/s ---|--- A3 | A4 b1 b = 1/s -- b2- Parameters:
- Fnumpy.ndarray of shape (n+1, n+1)
- affine_componentint
- Returns:
- Anumpy.ndarray of shape (n, n)
- bnumpy.ndarray of shape (n,)
Notes
This function uses the global tolerance defaults if
atolorrtolare set to None. See ddg.abc.NonExact for details.
- ddg.math.projective.is_similarity(F, affine_component=-1, atol=None, rtol=None)[source]
Check whether an affine transformation F is a similarity transformation.
- Parameters:
- Fnumpy.ndarray of shape (n+1, n+1)
The affine transformation to check.
- affine_componentint, default=-1
The diagonal index of affine component.
- atol, rtolfloat
- Returns:
- bool
- True if F is a similarity transformation.
Notes
This function uses the global tolerance defaults if
atolorrtolare set to None. See ddg.abc.NonExact for details.
- ddg.math.projective.translation(normal, direction, atol=None, rtol=None)[source]
Projective translation.
Returns the matrix
I + direction @ normal.T
This transformation fixes all vectors v in the hyperplane orthogonal to
normal. It can also be thought of as mappingv -> v + dot(normal, v) * direction
- Parameters:
- normal, directionnumpy.ndarray of shape (n,)
directionmust lie in the hyperplane orthogonal tonormal.- atol, rtolfloat
- Returns:
- numpy.ndarray of shape (n, n)
- Raises:
- ValueError
If the dimensions of
normalanddirectiondo not match.If
directionis not orthogonal tonormal.
Notes
This function uses the global tolerance defaults if
atolorrtolare set to None. See ddg.abc.NonExact for details.
- ddg.math.projective.translations_from_quad_3d(x00, x10, x11, x01, atol=None, rtol=None)[source]
Translations that map along a quadrilateral in RP2.
Returns two projective translations
T1,T2of RP2 such thatT1 x01 ---> x11 ^ ^ T2 | | T2 | | x00 ---> x10 T1- Parameters:
- x00, x10, x11, x01numpy.ndarray of shape (3,)
- Returns:
- T1, T2numpy.ndarray of shape (4, 4)
Notes
This function uses the global tolerance defaults if
atolorrtolare set to None. See ddg.abc.NonExact for details.
- ddg.math.projective.translations_from_quad_4d(x00, x10, x11, x01, n, atol=None, rtol=None)[source]
Translations that map along a quadrilateral in a plane in RP3.
Returns two projective translations
T1,T2of RP3 such thatT1 x01 ---> x11 ^ ^ T2 | | T2 | | x00 ---> x10 T1- Parameters:
- x00, x10, x11, x01, nnumpy.ndarray of shape (4,)
The corners of the quadrilateral must lie in the plane orthogonal to n.
- Returns:
- T1, T2numpy.ndarray of shape (4, 4)
Notes
This function uses the global tolerance defaults if
atolorrtolare set to None. See ddg.abc.NonExact for details.