View Source Exray.Shapes.Collision (Exray v0.6.0)

Check if two things intersect.

Summary

Functions

Check collision between circle and rectangle

Check the collision between two lines defined by two points each, returns collision point by reference

Check if point is inside circle

Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]

Check if point is within a polygon described by array of vertices

Check if point is inside rectangle

Check if point is inside a triangle

Check collision between two rectangles

Get collision rectangle for two rectangles collision

Functions

Link to this function

check_collision_circle_rec(center, radius, rec)

View Source
@spec check_collision_circle_rec(
  center :: Exray.Structs.Vector2.t(),
  radius :: float(),
  rec :: Exray.Structs.Rectangle.t()
) :: colliding :: boolean()

Check collision between circle and rectangle

Link to this function

check_collision_circles(center1, radius1, center2, radius2)

View Source
@spec check_collision_circles(
  center1 :: Exray.Structs.Vector2.t(),
  radius1 :: float(),
  center2 :: Exray.Structs.Vector2.t(),
  radius2 :: float()
) :: colliding :: boolean()

Check collision between two circles

Link to this function

check_collision_lines(start_pos_1, end_pos_1, start_pos_2, end_pos_2, collision_point)

View Source
@spec check_collision_lines(
  start_pos_1 :: Exray.Structs.Vector2.t(),
  end_pos_1 :: Exray.Structs.Vector2.t(),
  start_pos_2 :: Exray.Structs.Vector2.t(),
  end_pos_2 :: Exray.Structs.Vector2.t(),
  collision_point :: [Exray.Structs.Vector2.t()]
) :: colliding :: boolean()

Check the collision between two lines defined by two points each, returns collision point by reference

Link to this function

check_collision_point_circle(point, center, radius)

View Source
@spec check_collision_point_circle(
  point :: Exray.Structs.Vector2.t(),
  center :: Exray.Structs.Vector2.t(),
  radius :: float()
) :: colliding :: boolean()

Check if point is inside circle

Link to this function

check_collision_point_line(point, p1, p2, threshold)

View Source
@spec check_collision_point_line(
  point :: Exray.Structs.Vector2.t(),
  p1 :: Exray.Structs.Vector2.t(),
  p2 :: Exray.Structs.Vector2.t(),
  threshold :: integer()
) :: colliding :: boolean()

Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]

Link to this function

check_collision_point_poly(point, points)

View Source
@spec check_collision_point_poly(
  point :: Exray.Structs.Vector2.t(),
  points :: [Exray.Structs.Vector2.t()]
) :: colliding :: boolean()

Check if point is within a polygon described by array of vertices

Link to this function

check_collision_point_rec(point, rec)

View Source
@spec check_collision_point_rec(
  point :: Exray.Structs.Vector2.t(),
  rec :: Exray.Structs.Rectangle.t()
) ::
  colliding :: boolean()

Check if point is inside rectangle

Link to this function

check_collision_point_triangle(point, p1, p2, p3)

View Source
@spec check_collision_point_triangle(
  point :: Exray.Structs.Vector2.t(),
  p1 :: Exray.Structs.Vector2.t(),
  p2 :: Exray.Structs.Vector2.t(),
  p3 :: Exray.Structs.Vector2.t()
) :: colliding :: boolean()

Check if point is inside a triangle

Link to this function

check_collision_recs(rec1, rec2)

View Source
@spec check_collision_recs(
  rec1 :: Exray.Structs.Rectangle.t(),
  rec2 :: Exray.Structs.Rectangle.t()
) ::
  colliding :: boolean()

Check collision between two rectangles

Link to this function

get_collision_rec(rec1, rec2)

View Source
@spec get_collision_rec(
  rec1 :: Exray.Structs.Rectangle.t(),
  rec2 :: Exray.Structs.Rectangle.t()
) ::
  rectangle :: Exray.Structs.Rectangle.t()

Get collision rectangle for two rectangles collision