ddg.abc module
- class ddg.abc.Transformable[source]
Bases:
objectMakes a class transformable by keeping a stack of transformations.
It is assumed that the transformations are functions. If a matrix is passed to push_transformation, it will be converted to a function.
- push_transformation(f)[source]
Add a transformation to the trafo-stack.
- Parameters:
- fnumpy.ndarray or function
- transform(f)[source]
Wrapper for
push_transformation.See also
- property transformation
Composition of all transformations on the stack.
- Returns:
- function
- class ddg.abc.LinearTransformable(trafo_dimension)[source]
Bases:
TransformableMakes a class transformable by keeping a stack of transformations.
It is assumed that the transformations are matrices.
- Attributes:
- trafo_dimensionint
An empty transformation stack returns np.eye(_trafo_dimension).
- property transformation
Product of all matrices on the stack.
- Returns:
- numpy.ndarray
- change_affine_picture(before, after=-1)[source]
Transform the object to a different affine view.
Dehomogenizing the object post-transform with affine component
afterwill produce the same affine picture as dehomogenizing the object pre-transform with affine componentbefore.The actual transformation that achieves this just permutes the homogeneous coordinates as follows: It deletes the entry at
beforeand inserts it again at positionafter.Here are two examples of how you might use this function:
You defined a projective object
Xwith a certain affine picture in mind and you followed our convention of using affine component -1. You now want to see what it would look like when dehomogenized using a different affine componenti. To do this, you would just doX.change_affine_picture(i)and then visualize the object normally.You don’t like our convention of dehomogenizing by the last component and want to define your object
Xwith the affine picture with respect to affine componentiin mind. To visualize your object as you imagine it, you would also doX.change_affine_picture(i). To change back, you can doX.change_affine_picture(-1, i).
- Parameters:
- beforeint
- afterint (default=-1)
- pop_transformation()
Pop transformation from the trafo-stack.
- Returns:
- function
- transform(f)
Wrapper for
push_transformation.See also