transform

package
v0.0.0-...-1effa6f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2021 License: AGPL-3.0, AGPL-3.0-only Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matrix

type Matrix [9]float64

Matrix is a linear transform matrix in homogenous coordinates. PDF coordinate transforms are always affine so we only need 6 of these. See newMatrix.

func IdentityMatrix

func IdentityMatrix() Matrix

IdentityMatrix returns the identity transform.

func NewMatrix

func NewMatrix(a, b, c, d, tx, ty float64) Matrix

NewMatrix returns an affine transform matrix laid out in homogenous coordinates as

a  b  0
c  d  0
tx ty 1

func RotationMatrix

func RotationMatrix(angle float64) Matrix

RotationMatrix returns a matrix that rotates by angle `angle`, specified in radians.

func ScaleMatrix

func ScaleMatrix(x, y float64) Matrix

ScaleMatrix returns a matrix that scales by `x`,`y`.

func ShearMatrix

func ShearMatrix(x, y float64) Matrix

ShearMatrix returns a matrix that shears `x`,`y`.

func TranslationMatrix

func TranslationMatrix(tx, ty float64) Matrix

TranslationMatrix returns a matrix that translates by `tx`,`ty`.

func (*Matrix) Angle

func (m *Matrix) Angle() float64

Angle returns the angle of the affine transform in `m` in degrees.

func (*Matrix) Clone

func (m *Matrix) Clone() Matrix

Clone returns a copy of the current matrix.

func (*Matrix) Concat

func (m *Matrix) Concat(b Matrix)

Concat sets `m` to `b` × `m`. `b` needs to be created by newMatrix. i.e. It must be an affine transform.

b00 b01 0     m00 m01 0     b00*m00 + b01*m01        b00*m10 + b01*m11        0
b10 b11 0  ×  m10 m11 0  ➔  b10*m00 + b11*m01        b10*m10 + b11*m11        0
b20 b21 1     m20 m21 1     b20*m00 + b21*m10 + m20  b20*m01 + b21*m11 + m21  1

func (Matrix) Mult

func (m Matrix) Mult(b Matrix) Matrix

Mult returns `b` × `m`.

func (*Matrix) Rotate

func (m *Matrix) Rotate(angle float64)

Rotate rotates the current matrix by angle `angle`, specified in radians.

func (*Matrix) Scale

func (m *Matrix) Scale(x, y float64)

Scale scales the current matrix by `x`,`y`.

func (*Matrix) ScalingFactorX

func (m *Matrix) ScalingFactorX() float64

ScalingFactorX returns the X scaling of the affine transform.

func (*Matrix) ScalingFactorY

func (m *Matrix) ScalingFactorY() float64

ScalingFactorY returns the Y scaling of the affine transform.

func (*Matrix) Set

func (m *Matrix) Set(a, b, c, d, tx, ty float64)

Set sets `m` to affine transform a,b,c,d,tx,ty.

func (*Matrix) Shear

func (m *Matrix) Shear(x, y float64)

Shear shears the current matrix by `x',`y`.

func (Matrix) String

func (m Matrix) String() string

String returns a string describing `m`.

func (*Matrix) Transform

func (m *Matrix) Transform(x, y float64) (float64, float64)

Transform returns coordinates `x`,`y` transformed by `m`.

func (*Matrix) Translate

func (m *Matrix) Translate(x, y float64)

Translate appends a translation of `x`,`y` to `m`. m.Translate(dx, dy) is equivalent to m.Concat(NewMatrix(1, 0, 0, 1, dx, dy))

func (*Matrix) Translation

func (m *Matrix) Translation() (float64, float64)

Translation returns the translation part of `m`.

func (*Matrix) Unrealistic

func (m *Matrix) Unrealistic() bool

Unrealistic returns true if `m` is too small to have been created intentionally. If it returns true then `m` probably contains junk values, due to some processing error in the PDF generator or our code.

type Point

type Point struct {
	X float64
	Y float64
}

Point defines a point (X,Y) in Cartesian coordinates.

func NewPoint

func NewPoint(x, y float64) Point

NewPoint returns a Point at `(x,y)`.

func (Point) Displace

func (p Point) Displace(delta Point) Point

Displace returns a new Point at location `p` + `delta`.

func (Point) Distance

func (a Point) Distance(b Point) float64

Distance returns the distance between `a` and `b`.

func (Point) Interpolate

func (a Point) Interpolate(b Point, t float64) Point

Interpolate does linear interpolation between point `a` and `b` for value `t`.

func (Point) Rotate

func (p Point) Rotate(theta float64) Point

Rotate returns a new Point at `p` rotated by `theta` degrees.

func (*Point) Set

func (p *Point) Set(x, y float64)

Set mutates `p` and sets to coordinates `(x, y)`.

func (Point) String

func (p Point) String() string

String returns a string describing `p`.

func (*Point) Transform

func (p *Point) Transform(a, b, c, d, tx, ty float64)

Transform mutates and transforms `p` by the affine transformation a, b, c, d, tx, ty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL