pyagg.affine module
Thirdparty library for handling affine transformations, by Sean Gillies, based on Casey Duncan's original code.
Classes
class Affine
Two dimensional affine transform for linear mapping from 2D coordinates to other 2D coordinates. Parallel lines are preserved by these transforms. Affine transforms can perform any combination of translations, scales/flips, shears, and rotations. Class methods are provided to conveniently compose transforms from these operations.
Internally the transform is stored as a 3x3 transformation matrix. The
transform may be constructed directly by specifying the first two rows of
matrix values as 6 floats. Since the matrix is an affine transform, the
last row is always (0, 0, 1)
.
:param members: 6 floats for the first two matrix rows. :type members: float
Ancestors (in MRO)
Methods
def almost_equals(
self, other)
Compare transforms for approximate equality.
:param other: Transform being compared.
:type other: Affine
:return: True if absolute difference between each element
of each respective tranform matrix < EPSILON
.
def flip(
cls, xflip=None, yflip=None)
Create a flip transform for one or two axis.
:param xflip: Flip the x axis. :type xflip: boolean :param yflip: Flip the y axis. :type yflip: boolean :rtype: Affine
def from_gdal(
cls, c, a, b, f, d, e)
def identity(
cls)
Return the identity transform.
:rtype: Affine
def itransform(
self, seq)
Transform a sequence of points or vectors in place.
:param seq: Mutable sequence of :class:~planar.Vec2
to be
transformed.
:returns: None, the input sequence is mutated in place.
def rotate(
cls, angle, pivot=None)
Create a rotation transform at the specified angle, optionally about the specified pivot point.
:param angle: Rotation angle in degrees :type angle: float :param pivot: Point to rotate about, if omitted the rotation is about the origin. :type pivot: sequence :rtype: Affine
def scale(
cls, *scaling)
Create a scaling transform from a scalar or vector.
:param scaling: The scaling factor. A scalar value will scale in both dimensions equally. A vector scaling value scales the dimensions independently. :type scaling: float or sequence :rtype: Affine
def shear(
cls, x_angle=0, y_angle=0)
Create a shear transform along one or both axes.
:param x_angle: Angle in degrees to shear along the x-axis. :type x_angle: float :param y_angle: Angle in degrees to shear along the y-axis. :type y_angle: float :rtype: Affine
def to_gdal(
self)
def translate(
cls, xoff, yoff)
Create a translation transform from an offset vector.
:param xoff: Translation x offset. :type xoff: float :param yoff: Translation y offset. :type yoff: float :rtype: Affine