geometry

package
v0.0.0-...-bbf78bc Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitObject

func InitObject(object *Object2D)

Types

type Bezier3

type Bezier3 struct {
	Object2D
	// contains filtered or unexported fields
}

Bezier3 implements a quadratic Bezier curve

func NewBezier3

func NewBezier3(p0, p1, p2 Point2D) *Bezier3

NewBezier3 returns a Bezier3 path defined by the given Point2Ds

func (*Bezier3) GetPoint

func (path *Bezier3) GetPoint(t float64) Point2D

GetPoint returns the point on the path for the given factor

type Bezier4

type Bezier4 struct {
	Object2D
	// contains filtered or unexported fields
}

Bezier4 implements a cubic Bezier curve

func NewBezier4

func NewBezier4(p0, p1, p2, p3 Point2D) *Bezier4

NewBezier4 returns a Bezier4 path defined by the given Point2Ds

func (*Bezier4) GetPoint

func (path *Bezier4) GetPoint(t float64) Point2D

GetPoint returns the point on the path for the given factor

type Circle

type Circle struct {
	Object2D
	// contains filtered or unexported fields
}

Circle encapsulates a simple circle shape defined by a center and a radius

func NewCircle

func NewCircle(center Point2D, radius float64) *Circle

func (*Circle) Definition

func (shape *Circle) Definition() []interface{}

func (*Circle) MBR

func (shape *Circle) MBR() image.Rectangle

type ComposedPath

type ComposedPath struct {
	// contains filtered or unexported fields
}

ComposedPath encapsulates a path composed of multiple independent ones

func NewComposedPath

func NewComposedPath(subpaths []Path) *ComposedPath

NewComposedPath returns a ComposedPath path composed of the given Paths

func (*ComposedPath) GetPoint

func (path *ComposedPath) GetPoint(t float64) Point2D

GetPoint returns the point on the path for the given factor

func (*ComposedPath) Rotate

func (path *ComposedPath) Rotate(a float64)

Rotate applies the given rotation to each composing subpath

func (*ComposedPath) Scale

func (path *ComposedPath) Scale(x, y float64)

Scale applies the given scaling to each composing subpath

func (*ComposedPath) Translate

func (path *ComposedPath) Translate(x, y float64)

Translate applies the given translation to each composing subpath

type Hermite

type Hermite struct {
	Object2D
	// contains filtered or unexported fields
}

Hermite implements a cubic Hermite curve

func NewHermite

func NewHermite(p0, p1, m0, m1 Point2D) *Hermite

NewHermite returns a Hermite path defined by the given Point2Ds

func (*Hermite) GetPoint

func (path *Hermite) GetPoint(t float64) Point2D

GetPoint returns the point on the path for the given factor

type IObject2D

type IObject2D interface {
	Translate(float64, float64) *Object2D
	Scale(float64, float64) *Object2D
	Rotate(float64) *Object2D
}

type ModelMatrix2D

type ModelMatrix2D [3][3]float64

func Eye2D

func Eye2D() ModelMatrix2D

func MM2D

func MM2D(p Point2D) ModelMatrix2D

func RotateMatrix

func RotateMatrix(a float64) *ModelMatrix2D

func ScaleMatrix

func ScaleMatrix(sx, sy float64) *ModelMatrix2D

func TranslateMatrix

func TranslateMatrix(tx, ty float64) *ModelMatrix2D

func (*ModelMatrix2D) Apply

func (model *ModelMatrix2D) Apply(p Point2D) Point2D

func (*ModelMatrix2D) Multiply

func (model *ModelMatrix2D) Multiply(other *ModelMatrix2D) ModelMatrix2D

func (*ModelMatrix2D) Rotate

func (model *ModelMatrix2D) Rotate(a float64)

func (*ModelMatrix2D) Scale

func (model *ModelMatrix2D) Scale(x, y float64)

func (*ModelMatrix2D) Translate

func (model *ModelMatrix2D) Translate(x, y float64)

type Object2D

type Object2D struct {
	// contains filtered or unexported fields
}

func (*Object2D) Inverse

func (object *Object2D) Inverse() *ModelMatrix2D

func (*Object2D) Model

func (object *Object2D) Model() *ModelMatrix2D

func (*Object2D) Rotate

func (object *Object2D) Rotate(a float64) *Object2D

func (*Object2D) Scale

func (object *Object2D) Scale(x, y float64) *Object2D

func (*Object2D) Translate

func (object *Object2D) Translate(x, y float64) *Object2D

type Path

type Path interface {
	IObject2D
	// GetPoint returns the point found at the given ratio
	// between the two ends of the path
	GetPoint(float64) Point2D
}

Path is an interface that encapsulates any kind of path

type Point2D

type Point2D struct {
	X, Y float64
}

Point2D encapsulates the coordinates for a point in 2D space

func Pt2D

func Pt2D(X, Y float64) Point2D

Pt2D returns a Point2D with the given coordinates

func (Point2D) Diff

func (p Point2D) Diff(q Point2D) Point2D

Diff returns the difference between the current Point2D and the given Point2D

func (Point2D) Dist

func (p Point2D) Dist(q Point2D) float64

Dist returns the euclidean distance between the current Point2D and the given Point2D

func (Point2D) DistSq

func (p Point2D) DistSq(q Point2D) float64

DistSq returns the euclidean distance squared between the current Point2D and the given Point2D

func (*Point2D) Rotate

func (p *Point2D) Rotate(a float64)

Rotate applies a rotation with the given radians

func (*Point2D) Scale

func (p *Point2D) Scale(x, y float64)

Scale applies a scaling with the given values

func (*Point2D) Translate

func (p *Point2D) Translate(x, y float64)

Translate applies a translation with the given values

type Polygon

type Polygon struct {
	Object2D
	// contains filtered or unexported fields
}

Polygon encapsulates a polygon defined by a list of points, where the last is implicitly bound to the first

func NewPolygon

func NewPolygon(points []Point2D) *Polygon

func (*Polygon) AddPoint

func (shape *Polygon) AddPoint(p Point2D)

func (*Polygon) Contains

func (shape *Polygon) Contains(p Point2D) bool

func (*Polygon) Definition

func (shape *Polygon) Definition() []interface{}

func (*Polygon) MBR

func (shape *Polygon) MBR() image.Rectangle

type Segment

type Segment struct {
	Object2D
	// contains filtered or unexported fields
}

Segment encapsulates a simple straight path defined between 2 points

func NewSegment

func NewSegment(p0, p1 Point2D) *Segment

NewSegment returns a Segment path defined by the given Point2Ds

func (*Segment) GetPoint

func (path *Segment) GetPoint(t float64) Point2D

GetPoint returns the point on the path for the given factor

type Shape

type Shape interface {
	IObject2D
	// Definition returns the data needed to define the shape
	Definition() []interface{}
	// MBR = Minimum Bounding Rectangle returns the smallest rectangle
	// that contains the entire shape; should be used to minimize the
	// Inside method calls
	MBR() image.Rectangle
}

Shape is an interface that encapsulates any kind of 2D shape

Jump to

Keyboard shortcuts

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