geom

package
v0.0.0-...-7fee067 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw[T Drawable](shape T, d displayer, clr color.Color)

func Fill

func Fill[T Drawable](shape T, d displayer, clr color.Color)

Types

type Circle

type Circle struct {
	X float64
	Y float64
	R float64
}

func MakeCircle

func MakeCircle(x, y, r float64) Circle

func (Circle) ContainsPoint

func (c Circle) ContainsPoint(p Point) bool

func (Circle) Diameter

func (c Circle) Diameter() float64

func (Circle) Draw

func (c Circle) Draw(d displayer, clr color.Color)

func (Circle) Filled

func (c Circle) Filled(d displayer, clr color.Color)

func (Circle) HasOverlap

func (c Circle) HasOverlap(other Circle) bool

type Collision

type Collision struct {
	Point    Vector
	FarPoint Vector
	Normal   Vector
	TimeNear Vector
	TimeFar  Vector
	HitNear  float64
	HitFar   float64
}

type Drawable

type Drawable interface {
	Draw(d displayer, clr color.Color)
	Filled(d displayer, clr color.Color)
}

type Line

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

func MakeLine

func MakeLine(a, b Point) Line

func (Line) Draw

func (l Line) Draw(d displayer, clr color.Color)

func (Line) EvalX

func (l Line) EvalX(x float64) float64

func (Line) Intersection

func (l Line) Intersection(l2 Line) (Point, error)

func (Line) IsParrallel

func (l Line) IsParrallel(l1, l2 Line) bool

type Normal

type Normal struct{}

type Point

type Point struct {
	X float64
	Y float64
}

func MakePoint

func MakePoint(x, y float64) Point

func (Point) Draw

func (p Point) Draw(d displayer, c color.RGBA)

func (Point) ToVector

func (p Point) ToVector() Vector

type Ray

type Ray struct {
	Origin    Vector
	Direction Vector
}

func (Ray) Draw

func (r Ray) Draw(d displayer, clr color.Color)

type Rect

type Rect [4]float64

Rect a float64 slice with 4 elements []float64{x, y, width, height}

func MakeRect

func MakeRect(x, y, width, height float64) Rect

func (Rect) ContainsPoint

func (r Rect) ContainsPoint(p Point) bool

func (Rect) Dimension

func (r Rect) Dimension(i int) float64

Dimension returns the value of the i-th dimension

func (Rect) Dimensions

func (r Rect) Dimensions() int

Dimensions returns the total number of dimensions

func (Rect) Draw

func (r Rect) Draw(d displayer, clr color.Color)

func (Rect) Filled

func (r Rect) Filled(d displayer, clr color.Color)

func (Rect) GetCenter

func (r Rect) GetCenter() (float64, float64)

func (Rect) GetOverlap

func (r Rect) GetOverlap(other Rect) (float64, float64)

func (Rect) HasRayIntersection

func (r Rect) HasRayIntersection(ray Ray, collision *Collision) bool

HasRayIntersection returns true if an intersection exists the collision argument will contain information about the collision

func (Rect) IsAxisAlignedCollision

func (r Rect) IsAxisAlignedCollision(other Rect) bool

type Segment

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

type Triangle

type Triangle [3]Vector

func MakeTriangle

func MakeTriangle(vecs [3]Vector) Triangle

func (*Triangle) Centroid

func (t *Triangle) Centroid() Point

func (Triangle) Draw

func (t Triangle) Draw(d displayer, clr color.Color)

func (Triangle) Filled

func (t Triangle) Filled(d displayer, clr color.Color)

func (*Triangle) Rotate

func (t *Triangle) Rotate(angle float64)

type Vector

type Vector [2]float64

Vector a float64 slice with 2 elements [2]float64{x, y}

func MakeVector

func MakeVector(x, y float64) Vector

func (Vector) Add

func (v Vector) Add(other Vector) Vector

func (Vector) Divide

func (v Vector) Divide(other Vector) Vector

func (Vector) GetDirection

func (v Vector) GetDirection(b Vector) float64

func (Vector) GetDistance

func (v Vector) GetDistance(b Vector) float64

func (Vector) Multiply

func (v Vector) Multiply(other Vector) Vector

func (Vector) Offset

func (v Vector) Offset(o Vector) Vector

func (Vector) String

func (v Vector) String() string

func (Vector) Subtract

func (v Vector) Subtract(other Vector) Vector

func (Vector) ToPoint

func (v Vector) ToPoint() Point

Jump to

Keyboard shortcuts

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