triangle

package
v0.0.0-...-53ca9c9 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 6 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 struct {
	// contains filtered or unexported fields
}

Matrix is a 3x3 matrix.

A triangle in the matrix form is:

    | aa.x ab.x ac.x |
A = | aa.y ab.y ac.y |
    |  1    1    1   |

To transform a triangle into another triangle wee need to find M from :

M * A = B

which simplifies to :

M = B * Inv(A)

func (*Matrix) Mul

func (a *Matrix) Mul(b *Matrix) Matrix

Mul return a * b which are 3/3 matrixes

func (*Matrix) Mul1

func (a *Matrix) Mul1(b [3]float64) (x, y, z float64)

Mul1 returns a ( 3 by 3 ) * b ( 1 by 3)

func (*Matrix) TransformPoint

func (a *Matrix) TransformPoint(x, y int) (int, int)

TransformPoint gives you where point will be after trasforming it through a

type PossibilititesOpts

type PossibilititesOpts struct {
	// min distance ratio between two points
	LowerThreshold, UpperThreshold int

	MinArea int // in pixel
	// contains filtered or unexported fields
}

PossibilititesOpts is an option for EveryTriangles func

func (*PossibilititesOpts) DistanceInvalid

func (opts *PossibilititesOpts) DistanceInvalid(one, two image.Point) bool

DistanceInvalid returns true when distance is invalid ( too big or too small )

type Triangle

type Triangle [3]image.Point

A Triangle is made of three 2D points. A triangle is also a 3x3 matrix: | x1, x2, x3 | | y1, y2, y3 | | 1, 1, 1 |

func AllPossibilities

func AllPossibilities(opts PossibilititesOpts, points geometry.Points) []Triangle

AllPossibilities returns every possible triangle from the points.

func Unique

func Unique(input Triangles) []Triangle

Unique sorts input and and returns it with duplicates removed. Unique expects all triangles to have points sorted out. it will sort

func (*Triangle) Area

func (t *Triangle) Area() int

Area of the triangle

func (*Triangle) Bounds

func (t *Triangle) Bounds() (res image.Rectangle)

Bounds returns a rectangle containing triangle

func (*Triangle) Contains

func (t *Triangle) Contains(x, y int) bool

Contains point x,y ?

func (Triangle) Determinant

func (a Triangle) Determinant() int

Determinant of triangle matrix

func (Triangle) ExtractEquilateralTriangleFrom

func (a Triangle) ExtractEquilateralTriangleFrom(src image.Image) image.Image

ExtractEquilateralTriangleFrom will give you an equilateral triangle extract from src at coordinates of a.

func (Triangle) InverseMatrix

func (a Triangle) InverseMatrix() Matrix

InverseMatrix gives you the matrix inverse of a.

func (*Triangle) Len

func (t *Triangle) Len() int

func (*Triangle) Less

func (t *Triangle) Less(x, y int) bool

func (*Triangle) Swap

func (t *Triangle) Swap(x, y int)

type Triangles

type Triangles []Triangle

Triangles is a sortable array of triangles

func (Triangles) Diff

func (ts Triangles) Diff(x, y int) bool

func (Triangles) Len

func (ts Triangles) Len() int

func (Triangles) Less

func (ts Triangles) Less(x, y int) bool

func (Triangles) Swap

func (ts Triangles) Swap(x, y int)

Jump to

Keyboard shortcuts

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