Collision

Functions for detecting collisions between shapes.


Overlap

overlap(a: Rect, b: Rect) bool

Check if two rectangles overlap.

Parameters

  • a : The first rectangle to check for overlap.
  • b : The second rectangle to check for overlap.

Returns

bool : True if the rectangles overlap, otherwise False.


overlap(rect: Rect, circle: Circle) bool

Check if a rectangle and a circle overlap.

Parameters

  • rect : The rectangle to check for overlap.
  • circle : The circle to check for overlap.

Returns

bool : True if the rectangle and circle overlap, otherwise False.


overlap(rect: Rect, polygon: Polygon) bool

Check if a rectangle and a polygon overlap.

Parameters

  • rect : The rectangle to check for overlap.
  • polygon : The polygon to check for overlap.

Returns

bool : True if the rectangle and polygon overlap, otherwise False.


overlap(rect: Rect, line: Line) bool

Check if a rectangle and a line overlap.

Parameters

  • rect : The rectangle to check for overlap.
  • line : The line to check for overlap.

Returns

bool : True if the rectangle and line overlap, otherwise False.


overlap(rect: Rect, point: Vec2) bool

Check if a rectangle contains a point.

Parameters

  • rect : The rectangle to check.
  • point : The point to check.

Returns

bool : True if the rectangle contains the point, otherwise False.


overlap(a: Circle, b: Circle) bool

Check if two circles overlap.

Parameters

  • a : The first circle to check for overlap.
  • b : The second circle to check for overlap.

Returns

bool : True if the circles overlap, otherwise False.


overlap(circle: Circle, rect: Rect) bool

Check if a circle and a rectangle overlap.

Parameters

  • circle : The circle to check for overlap.
  • rect : The rectangle to check for overlap.

Returns

bool : True if the circle and rectangle overlap, otherwise False.


overlap(circle: Circle, line: Line) bool

Check if a circle and a line overlap.

Parameters

  • circle : The circle to check for overlap.
  • line : The line to check for overlap.

Returns

bool : True if the circle and line overlap, otherwise False.


overlap(circle: Circle, point: Vec2) bool

Check if a circle contains a point.

Parameters

  • circle : The circle to check.
  • point : The point to check.

Returns

bool : True if the circle contains the point, otherwise False.


overlap(polygon: Polygon, rect: Rect) bool

Check if a polygon and a rectangle overlap.

Parameters

  • polygon : The polygon to check for overlap.
  • rect : The rectangle to check for overlap.

Returns

bool : True if the polygon and rectangle overlap, otherwise False.


overlap(polygon: Polygon, point: Vec2) bool

Check if a polygon overlaps with a point.

Parameters

  • polygon : The polygon to check for overlap.
  • point : The point to check for overlap.

Returns

bool : True if the polygon and point overlap, otherwise False.


overlap(a: Line, b: Line) bool

Check if two lines overlap (intersect).

Parameters

  • a : The first line to check for overlap.
  • b : The second line to check for overlap.

Returns

bool : True if the lines intersect, otherwise False.


overlap(line: Line, rect: Rect) bool

Check if a line and a rectangle overlap.

Parameters

  • line : The line to check for overlap.
  • rect : The rectangle to check for overlap.

Returns

bool : True if the line and rectangle overlap, otherwise False.


overlap(line: Line, circle: Circle) bool

Check if a line and a circle overlap.

Parameters

  • line : The line to check for overlap.
  • circle : The circle to check for overlap.

Returns

bool : True if the line and circle overlap, otherwise False.


overlap(point: Vec2, rect: Rect) bool

Check if a point is contained within a rectangle.

Parameters

  • point : The point to check.
  • rect : The rectangle to check.

Returns

bool : True if the point is within the rectangle, otherwise False.


overlap(point: Vec2, circle: Circle) bool

Check if a point is contained within a circle.

Parameters

  • point : The point to check.
  • circle : The circle to check.

Returns

bool : True if the point is within the circle, otherwise False.


overlap(point: Vec2, polygon: Polygon) bool

Check if a point is contained within a polygon.

Parameters

  • point : The point to check.
  • polygon : The polygon to check.

Returns

bool : True if the point is within the polygon, otherwise False.

Contains

contains(outer: Rect, inner: Rect) bool

Check if a rectangle fully contains another rectangle.

Parameters

  • outer : The outer rectangle to check.
  • inner : The inner rectangle to check.

Returns

bool : True if the outer rectangle fully contains the inner rectangle, otherwise False.


contains(rect: Rect, circle: Circle) bool

Check if a rectangle fully contains a circle.

Parameters

  • rect : The rectangle to check.
  • circle : The circle to check.

Returns

bool : True if the rectangle fully contains the circle, otherwise False.


contains(rect: Rect, line: Line) bool

Check if a rectangle fully contains a line.

Parameters

  • rect : The rectangle to check.
  • line : The line to check.

Returns

bool : True if the rectangle fully contains the line, otherwise False.


contains(outer: Circle, inner: Circle) bool

Check if a circle fully contains another circle.

Parameters

  • outer : The outer circle to check.
  • inner : The inner circle to check.

Returns

bool : True if the outer circle fully contains the inner circle, otherwise False.


contains(circle: Circle, rect: Rect) bool

Check if a circle fully contains a rectangle.

Parameters

  • circle : The circle to check.
  • rect : The rectangle to check.

Returns

bool : True if the circle fully contains the rectangle, otherwise False.


contains(circle: Circle, line: Line) bool

Check if a circle fully contains a line.

Parameters

  • circle : The circle to check.
  • line : The line to check.

Returns

bool : True if the circle fully contains the line, otherwise False.