Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
geometry.c File Reference

Functions

bool circleCircleIntersection (circle_t circle1, circle_t circle2, vec_t *collisionVec)
 Check if two circles intersect.
 
bool circlePointIntersection (circle_t circle, vec_t point, vec_t *collisionVec)
 Check if a point and a circle intersect.
 
bool rectRectIntersection (rectangle_t rect1, rectangle_t rect2, vec_t *collisionVec)
 Check if two rectangles intersect.
 
bool circleRectIntersection (circle_t circle, rectangle_t rect, vec_t *collisionVec)
 Check if a circle and a rectangle intersect.
 
bool circleLineIntersection (circle_t circle, line_t line, vec_t *collisionVec)
 Check if a circle and a line intersect.
 
bool lineLineIntersection (line_t line1, line_t line2)
 Check if two lines intersect.
 
bool rectLineIntersection (rectangle_t rect, line_t line, vec_t *collisionVec)
 Check if a line intersects with a rectangle.
 
arrow_t initArrow (vec_t base, vec_t tip, int32_t wingLen)
 Initialize an arrow pointing from base to tip.
 

Function Documentation

◆ circleCircleIntersection()

bool circleCircleIntersection ( circle_t circle1,
circle_t circle2,
vec_t * collisionVec )

Check if two circles intersect.

Parameters
circle1[IN] One circle to check for intersection
circle2[IN] The other circle to check for intersection
collisionVec[OUT] A vector pointing from the second circle to the first in the direction of the collision. May be NULL.
Returns
true if the circles intersect or touch, false if they do not

◆ circlePointIntersection()

bool circlePointIntersection ( circle_t circle,
vec_t point,
vec_t * collisionVec )

Check if a point and a circle intersect.

Parameters
circle[IN] A circle to check for intersection
point[IN] A point to check for intersection
collisionVec[OUT] A vector pointing from the point to the circle in the direction of the collision. May be NULL.
Returns
true if the point intersects or touches the circle, false if it doesn't

◆ rectRectIntersection()

bool rectRectIntersection ( rectangle_t rect1,
rectangle_t rect2,
vec_t * collisionVec )

Check if two rectangles intersect.

Adapted from https://www.jeffreythompson.org/collision-detection/rect-rect.php

Parameters
rect1[IN] One rectangle to check for intersection
rect2[IN] The other rectangle to check for intersection
collisionVec[OUT] A vector pointing from the second rectangle to the first in the direction of the collision. May be NULL.
Returns
true if the rectangles intersect or touch, false if they do not

◆ circleRectIntersection()

bool circleRectIntersection ( circle_t circle,
rectangle_t rect,
vec_t * collisionVec )

Check if a circle and a rectangle intersect.

Adapted from https://www.jeffreythompson.org/collision-detection/circle-rect.php

Parameters
circle[IN] The circle to check for intersection
rect[IN] The rectangle to check for intersection
collisionVec[OUT] A vector pointing from the rectangle to the circle in the direction of the collision. May be NULL.
Returns
true if the shapes intersect or touch, false if they do not

◆ circleLineIntersection()

bool circleLineIntersection ( circle_t circle,
line_t line,
vec_t * collisionVec )

Check if a circle and a line intersect.

Adapted from https://www.jeffreythompson.org/collision-detection/line-circle.php

Parameters
circle[IN] A circle to test intersection
line[IN] A line to test intersection
collisionVec[OUT] A vector pointing from the line to the circle in the direction of the collision. This may be NULL.
Returns
true if the circle intersects the line, false if it doesn't

◆ lineLineIntersection()

bool lineLineIntersection ( line_t line1,
line_t line2 )

Check if two lines intersect.

Adapted from https://www.jeffreythompson.org/collision-detection/line-line.php

Parameters
line1[IN] One line to check for intersection
line2[IN] Another line to check for intersection
Returns
true if the lines intersect, false if they do not

◆ rectLineIntersection()

bool rectLineIntersection ( rectangle_t rect,
line_t line,
vec_t * collisionVec )

Check if a line intersects with a rectangle.

Adapted from https://www.jeffreythompson.org/collision-detection/line-rect.php

Parameters
rect[IN] A rectangle to check for intersection
line[IN] A line to check for intersection
collisionVec[OUT] A vector pointing from the rectangle to the line in the direction of the collision. May be NULL.
Returns
true if the line intersects the rectangle, false if it doesn't

◆ initArrow()

arrow_t initArrow ( vec_t base,
vec_t tip,
int32_t wingLen )

Initialize an arrow pointing from base to tip.

Parameters
baseThe point of the base of the arrow
tipThe point of the tip of the arrow
wingLenThe length of the wings of the arrowhead
Returns
The initialized arrow