Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
Geometry 2D
Collaboration diagram for Geometry 2D:

Functions

bj_bool bj_segment_hits_segment_2d (struct bj_vec2 a0, struct bj_vec2 a1, struct bj_vec2 b0, struct bj_vec2 b1)
bj_bool bj_check_segments_hit (struct bj_vec2 a0, struct bj_vec2 a1, struct bj_vec2 b0, struct bj_vec2 b1)
bj_bool bj_circle_hits_segment_2d (struct bj_vec2 c, bj_real r, struct bj_vec2 l0, struct bj_vec2 l1)
bj_bool bj_check_circle_segment_hit (struct bj_vec2 c, bj_real r, struct bj_vec2 l0, struct bj_vec2 l1)

Detailed Description

2D Geometry utilities

Function Documentation

◆ bj_check_circle_segment_hit()

bj_bool bj_check_circle_segment_hit ( struct bj_vec2 c,
bj_real r,
struct bj_vec2 l0,
struct bj_vec2 l1 )
Deprecated
Renamed to bj_circle_hits_segment_2d. Removed in 2.0.

◆ bj_check_segments_hit()

bj_bool bj_check_segments_hit ( struct bj_vec2 a0,
struct bj_vec2 a1,
struct bj_vec2 b0,
struct bj_vec2 b1 )
Deprecated
Renamed to bj_segment_hits_segment_2d. Removed in 2.0.

◆ bj_circle_hits_segment_2d()

bj_bool bj_circle_hits_segment_2d ( struct bj_vec2 c,
bj_real r,
struct bj_vec2 l0,
struct bj_vec2 l1 )

Tell whether a circle overlaps a line segment.

Tests whether a circle centered at c with radius r intersects the line segment from l0 to l1.

Parameters
cCircle center position.
rCircle radius.
l0Start point of the line segment.
l1End point of the line segment.
Returns
BJ_TRUE if a point of the segment lies within the circle or on it, BJ_FALSE otherwise.

Touching counts: a segment tangent to the circle, or ending on it, hits, and so does one through the centre of a circle of radius 0. A point at a distance of up to r + BJ_EPSILON from c counts as on the circle, and a radius below 0 counts as a 0 one.

◆ bj_segment_hits_segment_2d()

bj_bool bj_segment_hits_segment_2d ( struct bj_vec2 a0,
struct bj_vec2 a1,
struct bj_vec2 b0,
struct bj_vec2 b1 )

Tell whether two line segments cross.

Tests whether the line segment from a0 to a1 intersects with the segment from b0 to b1 in 2D space.

Parameters
a0Start point of first segment.
a1End point of first segment.
b0Start point of second segment.
b1End point of second segment.
Returns
BJ_TRUE if the segments share at least one point, BJ_FALSE otherwise.

Touching counts: segments that meet only at an endpoint, or that overlap along one line, hit. The tests allow BJ_EPSILON as an absolute tolerance, on the position along each segment, from 0 at its start to 1 at its end, and on the cross products that tell whether the segments are parallel or on one line.

The mold for future collision predicates is bj_<shape>_hits_<shape>_2d.