BRL-CAD
sat.h
Go to the documentation of this file.
1/* S A T . H
2 * BRL-CAD
3 *
4 * Based on implementations in GeometircTools:
5 *
6 * https://github.com/davideberly/GeometricTools
7 *
8 * David Eberly, Geometric Tools, Redmond WA 98052
9 * Copyright (c) 1998-2022
10 *
11 * Distributed under:
12 *
13 * Boost Software License - Version 1.0 - August 17th, 2003
14 *
15 * Permission is hereby granted, free of charge, to any person or organization
16 * obtaining a copy of the software and accompanying documentation covered by
17 * this license (the "Software") to use, reproduce, display, distribute,
18 * execute, and transmit the Software, and to prepare derivative works of the
19 * Software, and to permit third-parties to whom the Software is furnished to
20 * do so, all subject to the following:
21 *
22 * The copyright notices in the Software and this entire statement, including
23 * the above license grant, this restriction and the following disclaimer, must
24 * be included in all copies of the Software, in whole or in part, and all
25 * derivative works of the Software, unless such copies or derivative works are
26 * solely in the form of machine-executable object code generated by a source
27 * language processor.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35 * DEALINGS IN THE SOFTWARE.
36 */
37
38/*----------------------------------------------------------------------*/
39/* @file sat.h */
40/** @addtogroup bg_sat */
41/** @{ */
42
43/**
44 * @brief
45 *
46 * Implementation of Separating Axis Theorem intersection tests
47 *
48 */
49
50#ifndef BG_SAT_H
51#define BG_SAT_H
52
53#include "common.h"
54#include "vmath.h"
55#include "bg/defines.h"
56
57__BEGIN_DECLS
58
59/**
60 * Test for an intersection between a line and an Axis-Aligned Bounding Box (AABB).
61 *
62 * Returns 1 if they intersect, 0 otherwise.
63 */
64BG_EXPORT extern int
66 point_t origin, vect_t ldir,
67 point_t aabb_center, vect_t aabb_extent
68 );
69
70/**
71 * Test for an intersection between a line and an Oriented Bounding Box (OBB).
72 *
73 * Returns 1 if they intersect, 0 otherwise.
74 */
75BG_EXPORT extern int
77 point_t origin, vect_t ldir,
78 point_t obb_center, vect_t obb_extent1, vect_t obb_extent2, vect_t obb_extent3
79 );
80
81/**
82 * Test for an intersection between a triangle and an Axis-Aligned Bounding Box (AABB).
83 *
84 * Returns 1 if they intersect, 0 otherwise.
85 */
86BG_EXPORT extern int
88 point_t v1, point_t v2, point_t v3,
89 point_t aabb_center, vect_t aabb_extent
90 );
91
92/**
93 * Test for an intersection between a triangle and an Oriented Bounding Box (OBB).
94 *
95 * Returns 1 if they intersect, 0 otherwise.
96 */
97BG_EXPORT extern int
99 point_t v1, point_t v2, point_t v3,
100 point_t obb_center, vect_t obb_extent1, vect_t obb_extent2, vect_t obb_extent3
101 );
102
103/**
104 * Test for an intersection between an Axis-Aligned Bounding Box (AABB) and an
105 * Oriented Bounding Box (OBB). The latter is defined by a center point and
106 * three perpendicular vectors from the center to the centers of the various
107 * faces.
108 *
109 * Returns 1 if they intersect, 0 otherwise.
110 */
111BG_EXPORT extern int
113 point_t aabb_min, point_t aabb_max,
114 point_t obb_center, vect_t obb_extent1, vect_t obb_extent2, vect_t obb_extent3
115 );
116
117/**
118 * Test for an intersection between two Oriented Bounding Boxes (OBBs). The
119 * boxes are defined by a center point and three perpendicular vectors from the
120 * center to the centers of the various faces.
121 *
122 * Returns 1 if they intersect, 0 otherwise.
123 */
124BG_EXPORT extern int
126 point_t obb1_center, vect_t obb1_extent1, vect_t obb1_extent2, vect_t obb1_extent3,
127 point_t obb2_center, vect_t obb2_extent1, vect_t obb2_extent2, vect_t obb2_extent3
128 );
129
130
131__END_DECLS
132
133#endif /* BG_SAT_H */
134/** @} */
135/*
136 * Local Variables:
137 * mode: C
138 * tab-width: 8
139 * indent-tabs-mode: t
140 * c-file-style: "stroustrup"
141 * End:
142 * ex: shiftwidth=4 tabstop=8
143 */
Header file for the BRL-CAD common definitions.
int bg_sat_tri_obb(point_t v1, point_t v2, point_t v3, point_t obb_center, vect_t obb_extent1, vect_t obb_extent2, vect_t obb_extent3)
int bg_sat_line_aabb(point_t origin, vect_t ldir, point_t aabb_center, vect_t aabb_extent)
Implementation of Separating Axis Theorem intersection tests.
int bg_sat_obb_obb(point_t obb1_center, vect_t obb1_extent1, vect_t obb1_extent2, vect_t obb1_extent3, point_t obb2_center, vect_t obb2_extent1, vect_t obb2_extent2, vect_t obb2_extent3)
int bg_sat_aabb_obb(point_t aabb_min, point_t aabb_max, point_t obb_center, vect_t obb_extent1, vect_t obb_extent2, vect_t obb_extent3)
int bg_sat_line_obb(point_t origin, vect_t ldir, point_t obb_center, vect_t obb_extent1, vect_t obb_extent2, vect_t obb_extent3)
int bg_sat_tri_aabb(point_t v1, point_t v2, point_t v3, point_t aabb_center, vect_t aabb_extent)
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition: vmath.h:345
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
fundamental vector, matrix, quaternion math macros