perspective

package
v0.0.0-...-6a756ba Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package perspective is used for creating and applying perspective transforms with the help of two quadrilaterals. A perspective transform can be used to map each point of one quadrilateral to another, given the corner coordinates for the source and destination quadrilaterals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Perspective

type Perspective struct {
	// SrcPoints is an array of the corner coordinates of the source
	// quadrilateral.
	SrcPoints [8]float64
	// DstPoints is an array of the corner coordinates of the destination
	// quadrilateral.
	DstPoints [8]float64
	// Coeffs is a homographic transform matrix, expressed as an array of
	// coefficients.
	Coeffs [9]float64
	// CoeffsInv is an inverse homographic transform matrix, expressed as an
	// array of coefficients.
	CoeffsInv [9]float64
}

func New

func New(srcPoints, dstPoints [8]float64) *Perspective

New takes the corner coordinates of the source and destination quadrilaterals in a [x1, y1, x2, y2, x3, y3, x4, y4] form.

func (*Perspective) Transform

func (t *Perspective) Transform(sx, sy float64) (dx, dy float64)

Transform maps a point from the source quadrilateral to the destination quadrilateral.

func (*Perspective) TransformInv

func (t *Perspective) TransformInv(sx, sy float64) (dx, dy float64)

TransformInv maps a point from the destination quadrilateral to the source quadrilateral.

Jump to

Keyboard shortcuts

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