MODULE v1.8.0

collision

pykraken.collision

Collision detection functions

Reference

PYTHON API

contains

function6 overloads
contains(outer: Rect, inner: Rect) -> bool
contains(rect: Rect, circle: Circle) -> bool
contains(rect: Rect, line: Line) -> bool
contains(outer: Circle, inner: Circle) -> bool
contains(circle: Circle, rect: Rect) -> bool
contains(circle: Circle, line: Line) -> bool

Overloaded function.

  1. contains(outer: Rect, inner: Rect) -> bool

Check whether one rectangle completely contains another rectangle.

Args

  • outer (Rect) — The outer rectangle.
  • inner (Rect) — The inner rectangle.

Returns

  • bool — True if the outer rectangle completely contains the inner rectangle.
  1. contains(rect: Rect, circle: Circle) -> bool

Check whether a rectangle completely contains a circle.

Args

  • rect (Rect) — The rectangle.
  • circle (Circle) — The circle.

Returns

  • bool — True if the rectangle completely contains the circle.
  1. contains(rect: Rect, line: Line) -> bool

Check whether a rectangle completely contains a line.

Args

  • rect (Rect) — The rectangle.
  • line (Line) — The line.

Returns

  • bool — True if the rectangle completely contains the line.
  1. contains(outer: Circle, inner: Circle) -> bool

Check whether one circle completely contains another circle.

Args

  • outer (Circle) — The outer circle.
  • inner (Circle) — The inner circle.

Returns

  • bool — True if the outer circle completely contains the inner circle.
  1. contains(circle: Circle, rect: Rect) -> bool

Check whether a circle completely contains a rectangle.

Args

  • circle (Circle) — The circle.
  • rect (Rect) — The rectangle.

Returns

  • bool — True if the circle completely contains the rectangle.
  1. contains(circle: Circle, line: Line) -> bool

Check whether a circle completely contains a line.

Args

  • circle (Circle) — The circle.
  • line (Line) — The line.

Returns

  • bool — True if the circle completely contains the line.

overlap

function17 overloads
overlap(a: Rect, b: Rect) -> bool
overlap(rect: Rect, circle: Circle) -> bool
overlap(rect: Rect, line: Line) -> bool
overlap(rect: Rect, point: Vec2) -> bool
overlap(a: Circle, b: Circle) -> bool
overlap(circle: Circle, rect: Rect) -> bool
overlap(circle: Circle, line: Line) -> bool
overlap(circle: Circle, point: Vec2) -> bool
overlap(a: Line, b: Line) -> bool
overlap(line: Line, rect: Rect) -> bool
overlap(line: Line, circle: Circle) -> bool
overlap(point: Vec2, rect: Rect) -> bool
overlap(point: Vec2, circle: Circle) -> bool
overlap(polygon: Polygon, point: Vec2) -> bool
overlap(point: Vec2, polygon: Polygon) -> bool
overlap(polygon: Polygon, rect: Rect) -> bool
overlap(rect: Rect, polygon: Polygon) -> bool

Overloaded function.

  1. overlap(a: Rect, b: Rect) -> bool

Check whether two rectangles overlap.

Args

  • a (Rect) — The first rectangle.
  • b (Rect) — The second rectangle.

Returns

  • bool — True if the rectangles overlap.
  1. overlap(rect: Rect, circle: Circle) -> bool

Check whether a rectangle and a circle overlap.

Args

  • rect (Rect) — The rectangle.
  • circle (Circle) — The circle.

Returns

  • bool — True if the rectangle and circle overlap.
  1. overlap(rect: Rect, line: Line) -> bool

Check whether a rectangle and a line overlap.

Args

  • rect (Rect) — The rectangle.
  • line (Line) — The line.

Returns

  • bool — True if the rectangle and line overlap.
  1. overlap(rect: Rect, point: Vec2) -> bool

Check whether a rectangle contains a point.

Args

  • rect (Rect) — The rectangle.
  • point (Vec2) — The point.

Returns

  • bool — True if the rectangle contains the point.
  1. overlap(a: Circle, b: Circle) -> bool

Check whether two circles overlap.

Args

  • a (Circle) — The first circle.
  • b (Circle) — The second circle.

Returns

  • bool — True if the circles overlap.
  1. overlap(circle: Circle, rect: Rect) -> bool

Check whether a circle and a rectangle overlap.

Args

  • circle (Circle) — The circle.
  • rect (Rect) — The rectangle.

Returns

  • bool — True if the circle and rectangle overlap.
  1. overlap(circle: Circle, line: Line) -> bool

Check whether a circle and a line overlap.

Args

  • circle (Circle) — The circle.
  • line (Line) — The line.

Returns

  • bool — True if the circle and line overlap.
  1. overlap(circle: Circle, point: Vec2) -> bool

Check whether a circle contains a point.

Args

  • circle (Circle) — The circle.
  • point (Vec2) — The point.

Returns

  • bool — True if the circle contains the point.
  1. overlap(a: Line, b: Line) -> bool

Check whether two lines overlap (intersect).

Args

  • a (Line) — The first line.
  • b (Line) — The second line.

Returns

  • bool — True if the lines intersect.
  1. overlap(line: Line, rect: Rect) -> bool

Check whether a line and a rectangle overlap.

Args

  • line (Line) — The line.
  • rect (Rect) — The rectangle.

Returns

  • bool — True if the line and rectangle overlap.
  1. overlap(line: Line, circle: Circle) -> bool

Check whether a line and a circle overlap.

Args

  • line (Line) — The line.
  • circle (Circle) — The circle.

Returns

  • bool — True if the line and circle overlap.
  1. overlap(point: Vec2, rect: Rect) -> bool

Check whether a point is inside a rectangle.

Args

  • point (Vec2) — The point.
  • rect (Rect) — The rectangle.

Returns

  • bool — True if the point is inside the rectangle.
  1. overlap(point: Vec2, circle: Circle) -> bool

Check whether a point is inside a circle.

Args

  • point (Vec2) — The point.
  • circle (Circle) — The circle.

Returns

  • bool — True if the point is inside the circle.
  1. overlap(polygon: Polygon, point: Vec2) -> bool

Check whether a polygon contains a point.

Args

  • polygon (Polygon) — The polygon.
  • point (Vec2) — The point.

Returns

  • bool — True if the polygon contains the point.
  1. overlap(point: Vec2, polygon: Polygon) -> bool

Check whether a point is inside a polygon.

Args

  • point (Vec2) — The point.
  • polygon (Polygon) — The polygon.

Returns

  • bool — True if the point is inside the polygon.
  1. overlap(polygon: Polygon, rect: Rect) -> bool

Check whether a polygon and a rectangle overlap.

Args

  • polygon (Polygon) — The polygon.
  • rect (Rect) — The rectangle.

Returns

  • bool — True if the polygon and rectangle overlap.
  1. overlap(rect: Rect, polygon: Polygon) -> bool

Check whether a rectangle and a polygon overlap.

Args

  • rect (Rect) — The rectangle.
  • polygon (Polygon) — The polygon.

Returns

  • bool — True if the rectangle and polygon overlap.

Find your next step

Start typing to search the manual.