geometry

package
v0.0.0-...-dff1495 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AABBTest

func AABBTest(a, b []Point) bool

Types

type Circle

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

func NewCircle

func NewCircle(center Point, r float64, dir Point, fanAngle float64) *Circle

func (*Circle) IntersectCircle

func (c *Circle) IntersectCircle(c2 Circle) bool

func (*Circle) IntersectRectangle

func (c *Circle) IntersectRectangle(r Rectangle) bool

func (*Circle) PointInShape

func (c *Circle) PointInShape(p Point) bool

func (*Circle) Pos

func (c *Circle) Pos() Point

func (*Circle) Radius

func (c *Circle) Radius() float64

func (*Circle) SetPos

func (c *Circle) SetPos(p Point)

func (*Circle) String

func (c *Circle) String() string

type Point

type Point struct {
	X, Y float64
}

func CalcOffsetPoint

func CalcOffsetPoint(pos, offset, dir Point) Point

dir needs to be magnitude of 1 if passing custom dir; returns a new Point which is pos + rotated offset

func CalcRandomPointFromCenter

func CalcRandomPointFromCenter(center Point, minRadius, maxRadius float64, rand *rand.Rand) Point

generates a random point that is between minRadius and maxRadius distance away from the provided center

func DefaultDirection

func DefaultDirection() Point

func DegreesToDirection

func DegreesToDirection(angle float64) Point

converts the given angle in degrees into a direction vector; + means clockwise

func (Point) Add

func (p Point) Add(p2 Point) Point

func (Point) Cross

func (p Point) Cross(p2 Point) float64

func (Point) Distance

func (p Point) Distance(p2 Point) float64

func (Point) Dot

func (p Point) Dot(p2 Point) float64

func (Point) Magnitude

func (p Point) Magnitude() float64

func (Point) MagnitudeSquared

func (p Point) MagnitudeSquared() float64

func (Point) Mul

func (p Point) Mul(p2 Point) Point

func (Point) Normalize

func (p Point) Normalize() Point

func (Point) Perp

func (p Point) Perp() Point

func (Point) Pos

func (p Point) Pos() Point

func (Point) Rotate

func (p Point) Rotate(dir Point) Point

dir needs to be magnitude of 1 if passing custom dir; https://gamedev.stackexchange.com/a/97586 https://en.wikipedia.org/wiki/Rotation_matrix

func (Point) String

func (p Point) String() string

func (Point) Sub

func (p Point) Sub(p2 Point) Point

type Projection

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

type Rectangle

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

center = true center of rect spawn = point rect extends outward from (centered on x, on y edge)

func NewRectangle

func NewRectangle(spawn Point, w, h float64, dir Point) *Rectangle

func (*Rectangle) IntersectCircle

func (r *Rectangle) IntersectCircle(c Circle) bool

func (*Rectangle) IntersectRectangle

func (r *Rectangle) IntersectRectangle(r2 Rectangle) bool

this exists but is unused because targets are all circles other interesting links: https://stackoverflow.com/a/115520 https://gist.github.com/shamansir/3007244 https://stackoverflow.com/a/6016515

func (*Rectangle) PointInShape

func (r *Rectangle) PointInShape(p Point) bool

func (*Rectangle) Pos

func (r *Rectangle) Pos() Point

func (*Rectangle) SetPos

func (r *Rectangle) SetPos(p Point)

func (*Rectangle) String

func (r *Rectangle) String() string

type Shape

type Shape interface {
	Pos() Point
	PointInShape(p Point) bool
	IntersectCircle(c Circle) bool
	IntersectRectangle(r Rectangle) bool
	String() string
}

type SingleTarget

type SingleTarget struct {
	Target targets.TargetKey
}

func (*SingleTarget) IntersectCircle

func (s *SingleTarget) IntersectCircle(in Circle) bool

func (*SingleTarget) IntersectRectangle

func (s *SingleTarget) IntersectRectangle(in Rectangle) bool

func (*SingleTarget) PointInShape

func (s *SingleTarget) PointInShape(p Point) bool

func (*SingleTarget) Pos

func (s *SingleTarget) Pos() Point

func (*SingleTarget) String

func (s *SingleTarget) String() string

Jump to

Keyboard shortcuts

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