Geometry Support

arcade.earclip

arcade.earclip(polygon: List[Union[Tuple[float, float], List[float]]]) List[Tuple[Tuple[float, float], Tuple[float, float], Tuple[float, float]]][source]

Simple earclipping algorithm for a given polygon p. polygon is expected to be an array of 2-tuples of the cartesian points of the polygon For a polygon with n points it will return n-2 triangles. The triangles are returned as an array of 3-tuples where each item in the tuple is a 2-tuple of the cartesian point.

Implementation Reference:

arcade.are_polygons_intersecting

arcade.are_polygons_intersecting(poly_a: Sequence[Union[Tuple[float, float], List[float]]], poly_b: Sequence[Union[Tuple[float, float], List[float]]]) bool[source]

Return True if two polygons intersect.

Parameters
  • poly_a (PointList) – List of points that define the first polygon.

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

Returns

True or false depending if polygons intersect

Rtype bool

arcade.clamp

arcade.clamp(a, low, high)[source]

Clamp a number between a range.

arcade.get_distance

arcade.get_distance(x1: float, y1: float, x2: float, y2: float)[source]

Get the distance between two points.

arcade.is_point_in_polygon

arcade.is_point_in_polygon(x: float, y: float, polygon_point_list) bool[source]

Use ray-tracing to see if point is inside a polygon

Args:

x: y: polygon_point_list:

Returns: bool

arcade.rotate_point

arcade.rotate_point(x: float, y: float, cx: float, cy: float, angle_degrees: float) List[float][source]

Rotate a point around a center.

Parameters
  • x – x value of the point you want to rotate

  • y – y value of the point you want to rotate

  • cx – x value of the center point you want to rotate around

  • cy – y value of the center point you want to rotate around

  • angle_degrees – Angle, in degrees, to rotate

Returns

Return rotated (x, y) pair

Return type

(float, float)

arcade.calculate_hit_box_points_detailed

arcade.calculate_hit_box_points_detailed(image: <module 'PIL.Image' from '/home/docs/checkouts/readthedocs.org/user_builds/arcade-library/envs/latest/lib/python3.8/site-packages/PIL/Image.py'>, hit_box_detail: float = 4.5) Union[List[arcade.arcade_types.NamedPoint], Tuple[arcade.arcade_types.NamedPoint, ...]][source]

Given an image, this returns points that make up a hit box around it. Attempts to trim out transparent pixels.

Parameters
  • image (Image) – Image get hit box from.

  • hit_box_detail (int) – How detailed to make the hit box. There’s a trade-off in number of points vs. accuracy.

Returns

List of points

arcade.calculate_hit_box_points_simple

arcade.calculate_hit_box_points_simple(image: <module 'PIL.Image' from '/home/docs/checkouts/readthedocs.org/user_builds/arcade-library/envs/latest/lib/python3.8/site-packages/PIL/Image.py'>) List[Union[Tuple[float, float], List[float]]][source]

Given an image, this returns points that make up a hit box around it. Attempts to trim out transparent pixels.

Parameters

image (Image) –

Returns

List of points