Learn R Programming

spatstat (version 1.31-3)

affine.psp: Apply Affine Transformation To Line Segment Pattern

Description

Applies any affine transformation of the plane (linear transformation plus vector shift) to a line segment pattern.

Usage

## S3 method for class 'psp':
affine(X, mat=diag(c(1,1)), vec=c(0,0), ...)

Arguments

X
Line Segment pattern (object of class "psp").
mat
Matrix representing a linear transformation.
vec
Vector of length 2 representing a translation.
...
Arguments passed to affine.owin affecting the handling of the observation window, if it is a binary pixel mask.

Value

  • Another line segment pattern (of class "psp") representing the result of applying the affine transformation.

Details

The line segment pattern, and its window, are subjected first to the linear transformation represented by mat (multiplying on the left by mat), and are then translated by the vector vec. The argument mat must be a nonsingular $2 \times 2$ matrix.

This is a method for the generic function affine.

See Also

affine, affine.owin, affine.ppp, affine.im, flipxy, rotate, shift

Examples

Run this code
oldpar <- par(mfrow=c(2,1))
  X <- psp(runif(10), runif(10), runif(10), runif(10), window=owin())
  plot(X, main="original")
  # shear transformation
  Y <- affine(X, matrix(c(1,0,0.6,1),ncol=2))
  plot(Y, main="transformed")
  par(oldpar)
  # 
  # rescale y coordinates by factor 0.2
  affine(X, diag(c(1,0.2)))

Run the code above in your browser using DataLab