ddg.abc module

class ddg.abc.Transformable[source]

Bases: object

Makes 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
pop_transformation()[source]

Pop transformation from the trafo-stack.

Returns:
function
transform(f)[source]

Wrapper for push_transformation.

property transformation

Composition of all transformations on the stack.

Returns:
function
class ddg.abc.LinearTransformable(trafo_dimension)[source]

Bases: Transformable

Makes 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).

push_transformation(f)[source]

Add a transformation to the trafo-stack.

Parameters:
fnumpy.ndarray
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 after will produce the same affine picture as dehomogenizing the object pre-transform with affine component before.

The actual transformation that achieves this just permutes the homogeneous coordinates as follows: It deletes the entry at before and inserts it again at position after.

Here are two examples of how you might use this function:

  1. You defined a projective object X with 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 component i. To do this, you would just do X.change_affine_picture(i) and then visualize the object normally.

  2. You don’t like our convention of dehomogenizing by the last component and want to define your object X with the affine picture with respect to affine component i in mind. To visualize your object as you imagine it, you would also do X.change_affine_picture(i). To change back, you can do X.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.