Documentation ¶
Index ¶
- func AABBTest(a, b []Point) bool
- func IntersectRectangle(r Rectangle, c Circle) bool
- type Circle
- type Point
- func (p1 Point) Add(p2 Point) Point
- func (p1 Point) Cross(p2 Point) float64
- func (p1 Point) Distance(p2 Point) float64
- func (p1 Point) Dot(p2 Point) float64
- func (p Point) Magnitude() float64
- func (p Point) MagnitudeSquared() float64
- func (p1 Point) Mul(p2 Point) Point
- func (p Point) Normalize() Point
- func (p1 Point) Perp() Point
- func (p Point) Pos() Point
- func (p Point) Rotate(dir Point) Point
- func (p Point) String() string
- func (p1 Point) Sub(p2 Point) Point
- type Projection
- type Rectangle
- type Shape
- type SingleTarget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntersectRectangle ¶
shared between Circle and Rectangle https://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection https://yal.cc/rot-rect-vs-circle-intersection/
Types ¶
type Circle ¶
type Circle struct {
// contains filtered or unexported fields
}
func (*Circle) IntersectCircle ¶
func (*Circle) IntersectRectangle ¶
func (*Circle) PointInShape ¶
type Point ¶
type Point struct {
X, Y float64
}
func CalcDirection ¶
func CalcOffsetPoint ¶
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 float64, 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 ¶
converts the given angle in degrees into a direction vector; + means clockwise
func (Point) MagnitudeSquared ¶
func (Point) Rotate ¶
dir needs to be magnitude of 1 if passing custom dir; https://gamedev.stackexchange.com/a/97586 https://en.wikipedia.org/wiki/Rotation_matrix
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 (*Rectangle) IntersectCircle ¶
func (*Rectangle) IntersectRectangle ¶
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 ¶
type SingleTarget ¶
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