2022-11-29 14:50:20 -07:00
|
|
|
#ifndef ARC_MATH_RECT_H_
|
|
|
|
|
#define ARC_MATH_RECT_H_
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2023-01-30 23:22:34 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-11-29 14:50:20 -07:00
|
|
|
typedef struct ARC_Rect {
|
|
|
|
|
int32_t x;
|
|
|
|
|
int32_t y;
|
|
|
|
|
int32_t w;
|
|
|
|
|
int32_t h;
|
|
|
|
|
} ARC_Rect;
|
|
|
|
|
|
|
|
|
|
typedef struct ARC_URect {
|
|
|
|
|
uint32_t x;
|
|
|
|
|
uint32_t y;
|
|
|
|
|
uint32_t w;
|
|
|
|
|
uint32_t h;
|
|
|
|
|
} ARC_URect;
|
|
|
|
|
|
2023-06-23 23:07:39 -06:00
|
|
|
typedef struct ARC_FRect {
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float w;
|
|
|
|
|
float h;
|
|
|
|
|
} ARC_FRect;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief centers rect on given bounds
|
|
|
|
|
*
|
|
|
|
|
* @param rect ARC_Rect to be centered
|
|
|
|
|
* @param bounds ARC_Rect area to center rect on
|
|
|
|
|
*/
|
|
|
|
|
void ARC_Rect_CenterOn(ARC_Rect *rect, ARC_Rect *bounds);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief centers rect on given bounds
|
|
|
|
|
*
|
|
|
|
|
* @param rect ARC_FRect to be centered
|
|
|
|
|
* @param bounds ARC_FRect area to center rect on
|
|
|
|
|
*/
|
|
|
|
|
void ARC_FRect_CenterOn(ARC_FRect *rect, ARC_FRect *bounds);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief casts FRect to Rect
|
|
|
|
|
*
|
|
|
|
|
* @param rect ARC_FRect to be casted
|
|
|
|
|
*
|
|
|
|
|
* @return ARC_Rect
|
|
|
|
|
*/
|
|
|
|
|
ARC_Rect ARC_FRect_CastToRect(ARC_FRect *rect);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief checks if two ARC_Rects intersect
|
|
|
|
|
*
|
|
|
|
|
* @param rect1 ARC_Rect that will be checked against rect2
|
|
|
|
|
* @param rect2 ARC_Rect that will be checked against rect1
|
|
|
|
|
*
|
|
|
|
|
* @return 1 if they intersect, 0 if they don't intersect
|
|
|
|
|
*/
|
2023-01-03 19:21:27 -07:00
|
|
|
int32_t ARC_Rect_Intersects(ARC_Rect *rect1, ARC_Rect *rect2);
|
|
|
|
|
|
2023-06-23 23:07:39 -06:00
|
|
|
/**
|
|
|
|
|
* @brief checks if ARC_Rect intersects a line
|
|
|
|
|
*
|
|
|
|
|
* @note need to update this documenation to word it better
|
|
|
|
|
*
|
|
|
|
|
* @param rect ARC_Rect that will be checked against line
|
|
|
|
|
* @param x1 first point's x value
|
|
|
|
|
* @param y1 first point's y value
|
|
|
|
|
* @param y2 second point's x value
|
|
|
|
|
* @param y2 second point's y value
|
|
|
|
|
*
|
|
|
|
|
* @return 1 if they intersect, 0 if they don't intersect
|
|
|
|
|
*/
|
2023-01-03 19:21:27 -07:00
|
|
|
int32_t ARC_Rect_LineIntersects(ARC_Rect *rect, int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2);
|
|
|
|
|
|
2023-01-30 23:22:34 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-11-29 14:50:20 -07:00
|
|
|
#endif // ARC_MATH_POINT_H_
|