Geometry Support

arcade.geometry.are_polygons_intersecting(poly_a: Sequence[tuple[float | int, float | int] | Vec2], poly_b: Sequence[tuple[float | int, float | int] | Vec2]) bool[source]

Check if two polygons intersect.

Parameters:
  • poly_a – List of points that define the first polygon.

  • poly_b – List of points that define the second polygon.

Returns:

True if polygons intersect, False otherwise

arcade.geometry.is_point_in_box(p: tuple[float | int, float | int] | Vec2, q: tuple[float | int, float | int] | Vec2, r: tuple[float | int, float | int] | Vec2) bool[source]

Checks if point q is inside the box defined by p and r.

Parameters:
  • p (Point2) – Start of box

  • q (Point2) – Point to check

  • r (Point2) – End of box

Returns:

True or False depending if point is in the box.

arcade.geometry.get_triangle_orientation(p: tuple[float | int, float | int] | Vec2, q: tuple[float | int, float | int] | Vec2, r: tuple[float | int, float | int] | Vec2) int[source]

Find the orientation of a triangle defined by (p, q, r)

The function returns the following integer values:

  • 0 –> p, q, and r are collinear

  • 1 –> Clockwise

  • 2 –> Counterclockwise

Parameters:
  • p – Point 1

  • q – Point 2

  • r – Point 3

Returns:

0, 1, or 2 depending on the orientation

Return type:

int

arcade.geometry.are_lines_intersecting(p1: tuple[float | int, float | int] | Vec2, q1: tuple[float | int, float | int] | Vec2, p2: tuple[float | int, float | int] | Vec2, q2: tuple[float | int, float | int] | Vec2) bool[source]

Given two lines defined by points p1, q1 and p2, q2, the function returns true if the two lines intersect.

Parameters:
  • p1 – Point 1

  • q1 – Point 2

  • p2 – Point 3

  • q2 – Point 4

Returns:

True or False depending if lines intersect

Return type:

bool

arcade.geometry.is_point_in_polygon(x: float, y: float, polygon: Sequence[tuple[float | int, float | int] | Vec2]) bool[source]

Checks if a point is inside a polygon of three or more points.

Parameters:
  • x – X coordinate of point

  • y – Y coordinate of point

  • polygon – List of points that define the polygon.

Returns:

True or False depending if point is inside polygon

Return type:

bool