Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
geometry.h
Go to the documentation of this file.
1
39#ifndef _GEOMETRY_H_
40#define _GEOMETRY_H_
41
42#include <stdint.h>
43#include <stdbool.h>
44#include "vector2d.h"
45
49typedef struct
50{
52 int32_t radius;
53} circle_t;
54
58typedef struct
59{
61 int32_t width;
62 int32_t height;
64
69typedef struct
70{
73} line_t;
74
82
83bool circleCircleIntersection(circle_t circle1, circle_t circle2, vec_t* collisionVec);
84bool circlePointIntersection(circle_t circle, vec_t point, vec_t* collisionVec);
85bool circleRectIntersection(circle_t circle, rectangle_t rect, vec_t* collisionVec);
86bool circleLineIntersection(circle_t circle, line_t line, vec_t* collisionVec);
87bool rectRectIntersection(rectangle_t rect1, rectangle_t rect2, vec_t* collisionVec);
88bool rectLineIntersection(rectangle_t rect, line_t line, vec_t* collisionVec);
89bool lineLineIntersection(line_t line1, line_t line2);
90
91arrow_t initArrow(vec_t base, vec_t tip, int32_t wingLen);
92
93#endif
bool lineLineIntersection(line_t line1, line_t line2)
Check if two lines intersect.
Definition geometry.c:269
int32_t radius
The radius of the circle.
Definition geometry.h:52
int32_t width
The width of the rectangle.
Definition geometry.h:61
bool rectLineIntersection(rectangle_t rect, line_t line, vec_t *collisionVec)
Check if a line intersects with a rectangle.
Definition geometry.c:332
vec_t p2
The other end point of the line segment.
Definition geometry.h:72
int32_t height
The height of the rectangle.
Definition geometry.h:62
vec_t wing2
The base of one of the other arrowhead wing.
Definition geometry.h:80
bool circleLineIntersection(circle_t circle, line_t line, vec_t *collisionVec)
Check if a circle and a line intersect.
Definition geometry.c:189
vec_t p1
One end point of the line segment.
Definition geometry.h:71
vec_t pos
The position of the center of the circle.
Definition geometry.h:51
bool circlePointIntersection(circle_t circle, vec_t point, vec_t *collisionVec)
Check if a point and a circle intersect.
Definition geometry.c:39
vec_t base
The base of the arrow.
Definition geometry.h:77
bool circleRectIntersection(circle_t circle, rectangle_t rect, vec_t *collisionVec)
Check if a circle and a rectangle intersect.
Definition geometry.c:116
vec_t tip
The tip of the arrow.
Definition geometry.h:78
bool circleCircleIntersection(circle_t circle1, circle_t circle2, vec_t *collisionVec)
Check if two circles intersect.
Definition geometry.c:15
arrow_t initArrow(vec_t base, vec_t tip, int32_t wingLen)
Initialize an arrow pointing from base to tip.
Definition geometry.c:422
vec_t wing1
The base of one of the arrowhead wings.
Definition geometry.h:79
bool rectRectIntersection(rectangle_t rect1, rectangle_t rect2, vec_t *collisionVec)
Check if two rectangles intersect.
Definition geometry.c:63
Definition geometry.h:76
Signed integer representation of a circle.
Definition geometry.h:50
Signed integer representation of a line segment.
Definition geometry.h:70
Signed integer representation of a rectangle.
Definition geometry.h:59
A 2D vector with signed integer X and Y components.
Definition vector2d.h:37