Documentation ¶
Index ¶
- func PointInCircle(point Vector, circle Circle) bool
- func PointInPolygon(point Vector, polygon Polygon) bool
- type Box
- type Circle
- type Polygon
- func (polygon Polygon) GetAABB() Polygon
- func (polygon Polygon) Rotate(angle float64) Polygon
- func (polygon Polygon) SetAngle(angle float64) Polygon
- func (polygon Polygon) SetOffset(offset Vector) Polygon
- func (polygon Polygon) SetPoints(points []Vector) 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)
- type Vector
- func (vector Vector) Add(another Vector) Vector
- func (vector Vector) Clone() Vector
- func (vector Vector) Copy(another Vector) Vector
- func (vector Vector) Dot(another Vector) float64
- func (vector Vector) Len() float64
- func (vector Vector) Len2() float64
- func (vector Vector) Normalize() Vector
- func (vector Vector) Perp() Vector
- func (vector Vector) Project(another Vector) Vector
- func (vector Vector) ProjectN(another Vector) Vector
- func (vector Vector) Reflect(axis Vector) Vector
- func (vector Vector) ReflectN(axis Vector) Vector
- func (vector Vector) Reverse() Vector
- func (vector Vector) Rotate(angle float64) Vector
- func (vector Vector) Scale(x float64) Vector
- func (vector Vector) ScaleDifferent(x, y float64) Vector
- func (vector Vector) String() string
- func (vector Vector) Sub(another Vector) Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PointInCircle ¶
PointInCircle returns true if the point is inside the circle.
func PointInPolygon ¶
PointInPolygon returns true if the point is inside a polygon.
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 Vector
Angle float64
Points, CalcPoints, Edges, Normals []Vector
}
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.
type Response ¶
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 ¶
TestCirclePolygon returns true if the circle collides with the polygon.
func TestPolygonCircle ¶
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.
type Vector ¶
type Vector struct {
X, Y float64
}
Vector is a simple 2D vector/point struct.
func (Vector) Clone ¶
Clone this vector coordinates to a new vector with the same coordinates as this one.
func (Vector) Rotate ¶
Rotate returns a new vector rotated counter-clockwise by the specified number of radians.
func (Vector) ScaleDifferent ¶
ScaleDifferent returns a new vector scaled in the direction of X and Y by value x and y respectively