File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/main/java/org/comroid/util Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .comroid .util ;
2
+
3
+ import org .comroid .api .data .Vector ;
4
+ import org .jetbrains .annotations .NotNull ;
5
+
6
+ public class MathUtil {
7
+ public static boolean aabb (@ NotNull Vector .N3 a , @ NotNull Vector .N3 b , @ NotNull Vector .N3 position ) {
8
+ // Get the minimum and maximum corners of the AABB
9
+ double minX = Math .min (a .getX (), b .getX ());
10
+ double maxX = Math .max (a .getX (), b .getX ());
11
+ double minY = Math .min (a .getY (), b .getY ());
12
+ double maxY = Math .max (a .getY (), b .getY ());
13
+ double minZ = Math .min (a .getZ (), b .getZ ());
14
+ double maxZ = Math .max (a .getZ (), b .getZ ());
15
+
16
+ // Check if the position is within the bounds
17
+ return (position .getX () >= minX && position .getX () <= maxX ) &&
18
+ (position .getY () >= minY && position .getY () <= maxY ) &&
19
+ (position .getZ () >= minZ && position .getZ () <= maxZ );
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments