matrix

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Identity = Matrix{1, 0, 0, 1, 0, 0}

Identity is the identity transformation.

View Source
var Zero = Matrix{0, 0, 0, 0, 0, 0}

Zero is an uninitialized transformation.

Functions

This section is empty.

Types

type Matrix

type Matrix [6]float64

Matrix contains a PDF transformation matrix. The elements are stored in the same order as for the "cm" operator.

A matrix object M = [a b c d e f] corresponds to the following 3x3 matrix:

/ a b 0 \
| c d 0 |
\ e f 1 /

A vector (x, y, 1) is transformed by M into

(x y 1) * M = (a*x+c*y+e, b*x+d*y+f, 1)

func Rotate

func Rotate(phi float64) Matrix

Rotate rotates the coordinate system by the given angle (in radians).

func Scale

func Scale(xScale, yScale float64) Matrix

Scale scales the coordinate system.

Drawing the unit square [0, 1] x [0, 1] after applying this transformation is equivalent to drawing the rectangle [0, xScale] x [0, yScale] in the original coordinate system.

func Translate

func Translate(dx, dy float64) Matrix

Translate moves the origin of the coordinate system.

Drawing the unit square [0, 1] x [0, 1] after applying this transformation is equivalent to drawing the rectangle [dx, dx+1] x [dy, dy+1] in the original coordinate system.

func (Matrix) Apply

func (M Matrix) Apply(x, y float64) (float64, float64)

Apply applies the transformation matrix to the given vector.

func (Matrix) Inv

func (M Matrix) Inv() Matrix

Inv computes the inverse of the transformation matrix M.

func (Matrix) Mul

func (M Matrix) Mul(B Matrix) Matrix

Mul multiplies two transformation matrices and returns the result. The result is equivalent to first applying M and then B.

Jump to

Keyboard shortcuts

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