Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_aabb.c
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
27#include "nilorea/n_common.h"
28#include "nilorea/n_log.h"
29#include "nilorea/n_str.h"
30#include "nilorea/n_aabb.h"
31
43 AABB3D box;
44 box.xMin = xMin;
45 box.yMin = yMin;
46 box.zMin = zMin;
47 box.xMax = xMax;
48 box.yMax = yMax;
49 box.zMax = zMax;
50 return box;
51}
52
62 return (x >= box.xMin && x <= box.xMax &&
63 y >= box.yMin && y <= box.yMax &&
64 z >= box.zMin && z <= box.zMax);
65}
66
74 return (box1.xMin <= box2.xMax && box1.xMax >= box2.xMin &&
75 box1.yMin <= box2.yMax && box1.yMax >= box2.yMin &&
76 box1.zMin <= box2.zMax && box1.zMax >= box2.zMin);
77}
AABB_VALUE yMin
first edge y coordinate
Definition n_aabb.h:51
AABB_VALUE yMax
second edge y coordinate
Definition n_aabb.h:57
AABB_VALUE zMax
second edge z coordinate
Definition n_aabb.h:59
AABB_VALUE xMax
second edge x coordinate
Definition n_aabb.h:55
AABB_VALUE xMin
first edge x coordinate
Definition n_aabb.h:49
AABB_VALUE zMin
first edge z coordinate
Definition n_aabb.h:53
bool doAABB3DsIntersect(AABB3D box1, AABB3D box2)
check if two 3D AABBs intersect
Definition n_aabb.c:73
bool isPointInsideAABB3D(AABB3D box, AABB_VALUE x, AABB_VALUE y, AABB_VALUE z)
check if a point is inside a 3D AABB
Definition n_aabb.c:61
double AABB_VALUE
type of a AABB component
Definition n_aabb.h:44
AABB3D createAABB3D(AABB_VALUE xMin, AABB_VALUE yMin, AABB_VALUE zMin, AABB_VALUE xMax, AABB_VALUE yMax, AABB_VALUE zMax)
create a new AABB3D box
Definition n_aabb.c:42
Axis-Aligned Bounding Box (AABB) algorithm.
Definition n_aabb.h:47
AABB3D module headers.
Common headers and low-level functions & define.
Generic log system.
N_STR and string function declaration.