Kohi Game Engine
geometry_2d.h
Go to the documentation of this file.
1 #ifndef _KOHI_MATH_GEOMETRY_2D_H_
2 #define _KOHI_MATH_GEOMETRY_2D_H_
3 
4 #include "defines.h"
5 #include "kmath.h"
6 #include "math_types.h"
7 
11 typedef struct circle_2d {
17 
25  return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
26 }
27 
35  f32 r_squared = circle.radius * circle.radius;
36  return vec2_distance_squared(point, circle.center) <= r_squared;
37 }
38 
39 #endif
This file contains global type definitions which are used throughout the entire engine and applicatio...
_Bool b8
8-bit boolean type
Definition: defines.h:58
float f32
32-bit floating point number
Definition: defines.h:47
#define KINLINE
Inline qualifier.
Definition: defines.h:208
KINLINE b8 point_in_circle_2d(vec2 point, circle_2d circle)
Indicates if the provided point is within the given circle.
Definition: geometry_2d.h:34
KINLINE b8 point_in_rect_2d(vec2 point, rect_2d rect)
Indicates if the provided point is within the given rectangle.
Definition: geometry_2d.h:24
struct circle_2d circle_2d
Represents a two-dimensional circle in space.
This file contains definitions for various important constant values as well as functions for many co...
KINLINE f32 vec2_distance_squared(vec2 vector_0, vec2 vector_1)
Returns the squared distance between vector_0 and vector_1. NOTE: If purely for comparison purposes,...
Definition: kmath.h:438
Contains various math types required for the engine.
Represents a two-dimensional circle in space.
Definition: geometry_2d.h:11
f32 radius
The radius of the circle.
Definition: geometry_2d.h:15
vec2 center
The center point of the circle.
Definition: geometry_2d.h:13
A 2-element vector.
Definition: math_types.h:19
f32 x
The first element.
Definition: math_types.h:25
f32 y
The second element.
Definition: math_types.h:35
A 4-element vector.
Definition: math_types.h:89
f32 height
The fourth element.
Definition: math_types.h:128
f32 x
The first element.
Definition: math_types.h:96
f32 width
The third element.
Definition: math_types.h:118
f32 y
The second element.
Definition: math_types.h:104