Documentation ¶
Index ¶
- func PointInCircle(point *vector2.Vector2, circle *Circle) bool
- func PointInPolygon(point *vector2.Vector2, polygon *Polygon) bool
- type Box
- type Circle
- type Polygon
- func (polygon *Polygon) Clone(pos *vector2.Vector2, angle float64) *Polygon
- func (polygon *Polygon) GetAABB() *Polygon
- func (polygon *Polygon) GetOriginal() *Polygon
- func (polygon *Polygon) Rotate(angle float64) *Polygon
- func (polygon *Polygon) SetAngle(angle float64) *Polygon
- func (polygon *Polygon) SetOffset(offset *vector2.Vector2) *Polygon
- func (polygon *Polygon) SetPoints(points []*vector2.Vector2) *Polygon
- func (polygon *Polygon) String() string
- func (polygon *Polygon) Translate(x, y float64) *Polygon
- type Response
- func NewResponse() *Response
- func TestCircleCircle(circleA, circleB *Circle) (isColliding bool, response *Response)
- func TestCirclePolygon(circle *Circle, polygon *Polygon) (isColliding bool, response *Response)
- func TestPolygonCircle(polygon *Polygon, circle *Circle) (isColliding bool, response *Response)
- func TestPolygonPolygon(polygonA, polygonB *Polygon) (isColliding bool, response *Response)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PointInCircle ¶
WARN: Returns incorrect result, use PointInPolygon(point, circle.ToPolygon()) instead of. This functions is not under maintance, but if you have solution you can create PR or issue.
PointInCircle returns true if the point is inside the circle.
Types ¶
type Box ¶
Box is a simple box with position, width and height.
type Circle ¶
Circle is a struct that represents a circle with a position and a raidus.
type Polygon ¶
type Polygon struct {
Pos, Offset *vector2.Vector2
Angle float64
Points, CalcPoints, Edges, Normals []*vector2.Vector2
// contains filtered or unexported fields
}
Polygon struct represents a polygon with position and edges in a counter-clockwise fashion.
func NewPolygon ¶
NewPolygon creates a new polygon with pos, offset, angle and points. Points is an array of pairs of float64 values, that are mapped into Vectors with X and Y. The first value is X and the second is Y. See test to understand better.
func (*Polygon) GetOriginal ¶
type Response ¶
type Response struct {
A, B interface{}
Overlap float64
OverlapN, OverlapV *vector2.Vector2
AInB, BInA bool
}
Response contains the information about an collision test.
func NewResponse ¶
func NewResponse() *Response
NewResponse is used to create a new response when necessary.
func TestCircleCircle ¶
TestCircleCircle returns true if the circles collide with each other.
func TestCirclePolygon ¶
WARN: Returns incorrect result, use TestPolygonPolygon(polygon, circle.ToPolygon()) instead of. This functions is not under maintance, but if you have solution you can create PR or issue.
TestCirclePolygon returns true if the circle collides with the polygon.
func TestPolygonCircle ¶
WARN: Returns incorrect result, use TestPolygonPolygon(polygon, circle.ToPolygon()) instead of. This functions is not under maintance, but if you have solution you can create PR or issue.
TestPolygonCircle returns true if the polygon collides with the circle.
func TestPolygonPolygon ¶
TestPolygonPolygon returns true if the polygons collide with each other.
func (*Response) NotColliding ¶
NotColliding is to be used when A and B are not colliding and response should be ignored.