Documentation
¶
Overview ¶
Package collide implements 2D collision detection.
Index ¶
- func Cross(p, q Point) float64
- func Distance(a Shape, xfa Transform, b Shape, xfb Transform) float64
- func Dot(p, q Point) float64
- func TimeOfImpact(simplex *Simplex, a Shape, sweepA Sweep, b Shape, sweepB Sweep) float64
- type Circle
- type Collision
- func Collide(a Shape, xfa Transform, b Shape, xfb Transform) *Collision
- func CollideCircleAndPolygon(a *Circle, xfa Transform, b *Polygon, xfb Transform) *Collision
- func CollideCircles(a *Circle, xfa Transform, b *Circle, xfb Transform) *Collision
- func CollidePolygonAndCircle(a *Polygon, xfa Transform, b *Circle, xfb Transform) *Collision
- func CollidePolygons(a *Polygon, xfa Transform, b *Polygon, xfb Transform) *Collision
- type Point
- type Polygon
- type Rotation
- type Shape
- type Simplex
- func (s *Simplex) ClosestPoint() Point
- func (s *Simplex) GJK(a Shape, xfa Transform, b Shape, xfb Transform)
- func (s *Simplex) Metric() float64
- func (s *Simplex) ReadCache(cache *SimplexCache, a Shape, xfa Transform, b Shape, xfb Transform)
- func (s *Simplex) WitnessPoints() (Point, Point)
- func (s *Simplex) WriteCache(cache *SimplexCache)
- type SimplexCache
- type Sweep
- type Transform
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collision ¶
Collision represents a collision.
func CollideCircleAndPolygon ¶
func CollideCircles ¶
func CollidePolygonAndCircle ¶
type Point ¶
type Point struct {
X, Y float64
}
A Point is an X, Y coordinate pair.
func (Point) LengthSquared ¶
LengthSquared returns the squared length of the vector p.
type Polygon ¶
Polygon represents a collection of points.
func NewPolygon ¶
NewPolygon returns a polygon with the given points specified in clockwise order.
type Rotation ¶
type Rotation struct {
Sin, Cos float64
}
Rotation represents a rotation.
func NewRotation ¶
NewRotation returns a new rotation of theta radians.
type Shape ¶
type Shape interface {
// contains filtered or unexported methods
}
Shape represents a shape.
type Simplex ¶
type Simplex struct {
// contains filtered or unexported fields
}
Simplex represents a simplex.
func (*Simplex) ClosestPoint ¶
ClosestPoint returns the closest point on the simplex to the origin.
func (*Simplex) WitnessPoints ¶
WitnessPoints returns the witness points on the original shapes.
func (*Simplex) WriteCache ¶
func (s *Simplex) WriteCache(cache *SimplexCache)
WriteCache populates the cache.
type SimplexCache ¶
type SimplexCache struct {
// contains filtered or unexported fields
}
SimplexCache is used to speed up repeated calls to distance functions.
type Sweep ¶
A Sweep interpolates between two positions and orientations.
func (Sweep) GetTransform ¶
GetTransform returns the transform at time t.