Geometry Support

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

Return True 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 or false depending if polygons intersect

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

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

Parameters:
  • p – Point 1

  • q – Point 2

  • r – Point 3

Returns:

True or false depending if points are collinear

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

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

The function returns 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 orientation

arcade.geometry.are_lines_intersecting(p1: Tuple[float | int, float | int] | Vec2 | Tuple[float | int, float | int, float | int] | Vec3, q1: Tuple[float | int, float | int] | Vec2 | Tuple[float | int, float | int, float | int] | Vec3, p2: Tuple[float | int, float | int] | Vec2 | Tuple[float | int, float | int, float | int] | Vec3, q2: Tuple[float | int, float | int] | Vec2 | Tuple[float | int, float | int, float | int] | Vec3) 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

arcade.geometry.is_point_in_polygon(x: float, y: float, polygon: Sequence[Tuple[float | int, float | int] | Vec2 | Tuple[float | int, float | int, float | int] | Vec3]) 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_point_list – List of points that define the polygon.

Returns:

True or false depending if point is inside polygon