geo

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TwoPi = math.Pi * 2
View Source
var (
	Zero = Point{0, 0}
)

Functions

func Coord

func Coord(x, y float64) geom.Coord

func CoordX

func CoordX(x float64) geom.Coord

func CoordY

func CoordY(y float64) geom.Coord

func Degrees

func Degrees(radians float64) float64

func Normalize

func Normalize(rad float64) float64

func Radians

func Radians(degrees int) float64

func RadiansF

func RadiansF(degrees float64) float64

Types

type Arc

type Arc struct {
	Circle
	Angle float64
	Width float64
}

func NewArc

func NewArc() Arc

func (Arc) Bounds

func (a Arc) Bounds() Rectangle

func (Arc) Centroid

func (a Arc) Centroid() Point

func (Arc) Draw

func (a Arc) Draw(g *gg.Context)

func (Arc) DrawCenter

func (a Arc) DrawCenter(g *gg.Context)

func (Arc) DrawOutline

func (a Arc) DrawOutline(g *gg.Context)

func (Arc) Intersect

func (a Arc) Intersect(geom Geometry) bool

func (Arc) Pos

func (a Arc) Pos() Point

func (*Arc) Rotate

func (a *Arc) Rotate(rad float64)

func (*Arc) RotateAround

func (a *Arc) RotateAround(rad float64, anchor Point)

func (*Arc) Translate

func (a *Arc) Translate(p Point)

type Circle

type Circle struct {
	Center Point
	Radius float64
}

func (Circle) Bounds

func (c Circle) Bounds() Rectangle

func (Circle) Centroid

func (c Circle) Centroid() Point

func (Circle) Draw

func (c Circle) Draw(g *gg.Context)

func (Circle) DrawCenter

func (c Circle) DrawCenter(g *gg.Context)

func (Circle) DrawOutline

func (c Circle) DrawOutline(g *gg.Context)

func (*Circle) Intersect

func (c *Circle) Intersect(geom Geometry) bool

func (Circle) Pos

func (c Circle) Pos() Point

func (Circle) Rotate

func (Circle) Rotate(rad float64)

func (*Circle) RotateAround

func (c *Circle) RotateAround(rad float64, anchor Point)

func (*Circle) Translate

func (c *Circle) Translate(p Point)

type Geometry

type Geometry interface {
	Pos() Point
	Centroid() Point
	Intersect(geom Geometry) bool
	Translate(p Point)
	Rotate(rad float64)
	RotateAround(rad float64, anchor Point)
	Bounds() Rectangle

	Draw(g *gg.Context)
	DrawOutline(g *gg.Context)
	DrawCenter(g *gg.Context)
	// contains filtered or unexported methods
}

type Group

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

func NewGroup

func NewGroup() Group

func (*Group) Add

func (g *Group) Add(triangle *Triangle)

func (Group) Bounds

func (g Group) Bounds() Rectangle

func (Group) Centroid

func (g Group) Centroid() Point

func (Group) Draw

func (g Group) Draw(ctx *gg.Context)

func (Group) DrawCenter

func (g Group) DrawCenter(ctx *gg.Context)

func (Group) DrawOutline

func (g Group) DrawOutline(ctx *gg.Context)

func (*Group) Intersect

func (g *Group) Intersect(ge Geometry) bool

func (Group) Pos

func (g Group) Pos() Point

func (*Group) Rotate

func (g *Group) Rotate(rad float64)

func (*Group) RotateAround

func (g *Group) RotateAround(rad float64, pivot Point)

func (*Group) SetPos

func (g *Group) SetPos(pos Point)

func (*Group) Translate

func (g *Group) Translate(p Point)

type Line

type Line struct {
	Start, End Point
}

func NewLine

func NewLine(start, end Point) Line

func (Line) Bounds

func (l Line) Bounds() Rectangle

func (Line) Centroid

func (l Line) Centroid() Point

func (Line) Draw

func (l Line) Draw(g *gg.Context)

func (Line) DrawCenter

func (l Line) DrawCenter(g *gg.Context)

func (Line) DrawOutline

func (l Line) DrawOutline(g *gg.Context)

func (Line) Intersect

func (l Line) Intersect(ge Geometry) bool

func (Line) Pos

func (l Line) Pos() Point

func (*Line) Rotate

func (l *Line) Rotate(rad float64)

func (*Line) RotateAround

func (l *Line) RotateAround(rad float64, pivot Point)

func (*Line) Translate

func (l *Line) Translate(p Point)

type Point

type Point struct {
	X, Y float64
}

func NewPointI

func NewPointI(x, y int32) Point

func Rotate

func Rotate(p Point, radian float64) Point

func RotateAround

func RotateAround(p Point, origin Point, radian float64) Point

func (Point) Add

func (p Point) Add(p2 Point) Point

func (Point) AddXY

func (p Point) AddXY(x, y float64) Point

func (Point) Bounds

func (p Point) Bounds() Rectangle

func (Point) Centroid

func (p Point) Centroid() Point

func (Point) DistanceTo

func (p Point) DistanceTo(p2 Point) float64

func (Point) Draw

func (p Point) Draw(g *gg.Context)

func (Point) DrawCenter

func (p Point) DrawCenter(g *gg.Context)

func (Point) DrawOutline

func (p Point) DrawOutline(g *gg.Context)

func (*Point) Intersect

func (p *Point) Intersect(ge Geometry) bool

func (Point) Invert

func (p Point) Invert() Point

func (Point) Pos

func (p Point) Pos() Point

func (*Point) Rotate

func (p *Point) Rotate(rad float64)

func (*Point) RotateAround

func (p *Point) RotateAround(rad float64, pivot Point)

func (Point) ToCoord

func (p Point) ToCoord() geom.Coord

func (*Point) Translate

func (p1 *Point) Translate(p Point)

type Point3D

type Point3D struct {
	X, Y, Z float64
}

type Rectangle

type Rectangle struct {
	Point
	W, H float64
}

func FromImgRect

func FromImgRect(r image.Rectangle) Rectangle

func NewRectangle

func NewRectangle(x, y, w, h float64) Rectangle

func ToRect

func ToRect(bounds *geom.Bounds) Rectangle

func (Rectangle) End

func (r Rectangle) End() Point

func (*Rectangle) Intersect

func (p *Rectangle) Intersect(ge Geometry) bool

func (Rectangle) ToFyneSize

func (r Rectangle) ToFyneSize() fyne.Size

func (Rectangle) ToImg

func (r Rectangle) ToImg() image.Rectangle

type Triangle

type Triangle struct {
	Orientation int32
	// contains filtered or unexported fields
}

func NewTriangle

func NewTriangle(pts Point, side int, orientation int32) *Triangle

func (Triangle) Bounds

func (t Triangle) Bounds() Rectangle

func (*Triangle) Centroid

func (t *Triangle) Centroid() Point

func (*Triangle) Draw

func (t *Triangle) Draw(g *gg.Context)

func (*Triangle) DrawCenter

func (t *Triangle) DrawCenter(g *gg.Context)

func (*Triangle) DrawOutline

func (t *Triangle) DrawOutline(g *gg.Context)

func (*Triangle) Intersect

func (t *Triangle) Intersect(ge Geometry) bool

func (*Triangle) Pos

func (t *Triangle) Pos() Point

func (*Triangle) Rotate

func (t *Triangle) Rotate(rad float64)

func (*Triangle) RotateAround

func (t *Triangle) RotateAround(rad float64, pivot Point)

func (*Triangle) Scale

func (t *Triangle) Scale(ratio float64)

func (*Triangle) Translate

func (t *Triangle) Translate(p Point)

Jump to

Keyboard shortcuts

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