An instance of this class represents an arbitrary transform. Here is the general form of the constructor:
is the 3×3 transform matrix as a
numpy array, or a sequence that can be passed to
to create the transform matrix.
These methods are available on instances of the class:
Given a point
Pt instance, return a
Pt instance representing the
Instead of using the
method, you may call the
instance directly. Pass it a
instance and it returns the transform point.
Runs the inverse transform. Returns the value
q such that
method would return
Returns the inverse transform as an
is another instance of the
Xform class. The method
returns a new transformation that is the
composition of both transformations.
For example, if
t1 is an
Xform instance representing a translation,
t2 is another
Xform instance representing a rotation, this expression
returns a new
Xform instance that
represents that translation followed by that
Returns the net offset of this transform as a
Pt instance. For example, if the
transform moves the origin to (3, 4), this method
Returns the net angle of rotation of this transform in radians.
Returns the net magnification that this transform has on a vector of length 1, as a scalar.
homcoord module includes three convenience
functions for constructing instances of the
Xform class that represent the three basic
Xlate ( *
Returns a translation transform. The arguments
Two values specifying the
One iterable argument containing the two values
x1 = Xlate ( 1.0, 2.0 ) # Move 1 to the right, up 2 x2 = Xlate ( [-1.0, -2.0] ) # Move 1 left, down 2
Returns a scaling transform.
may be either a single number or a
sequence of two numbers. If a single number, both
coordinates are scaled by multiplying them by
sequence of two values, the
x coordinate will be
multiplied by the first number and the
y coordinate multiplied by the
x3 = Xscale ( 2.0 ) # Make everything twice as big x4 = Xscale ( 4.0, 2.0 ) # Quadruple the x, double the y x5 = Xscale ( [4.0, 2.0] ) # Same as the previous line
Returns a rotation transform. The argument
counterclockwise angle of rotation expressed in radians.
Returns a transform that represents rotation around
a given point
by an angle