BRL-CAD
Loading...
Searching...
No Matches
aabb_ray.h
Go to the documentation of this file.
1/* A A B B _ R A Y . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2026 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20
21/*----------------------------------------------------------------------*/
22/* @file aabb_ray.h */
23/** @addtogroup bg_aabb_ray */
24/** @{ */
25
26/**
27 * @brief
28 *
29 * Intersection between an infinite line and an axis-aligned box.
30 *
31 */
32
33#ifndef BG_AABB_RAY_H
34#define BG_AABB_RAY_H
35
36#include "common.h"
37#include "vmath.h"
38#include "bg/defines.h"
39
40__BEGIN_DECLS
41
42/**
43 * Compute the inverse direction components for use with
44 * bg_isect_aabb_ray(). Components within SQRT_SMALL_FASTF of zero are
45 * represented by INFINITY. The input direction is not modified.
46 */
47BG_EXPORT extern void
48bg_ray_invdir(vect_t *invdir, const vect_t dir);
49
50/**
51 * Test the infinite line defined by opt and the reciprocal direction vector
52 * invdir against an axis-aligned bounding box. Despite its historical name,
53 * this function does not reject intersections behind opt: a successful result
54 * can have both output parameters negative. Callers that require a forward
55 * ray must additionally require *r_max >= 0.0.
56 *
57 * On success, r_min and r_max are the entry and exit line parameters. They
58 * are valid only when the function returns 1.
59 */
60BG_EXPORT extern int
62 fastf_t *r_min,
63 fastf_t *r_max,
64 const point_t opt,
65 const fastf_t *invdir,
66 const fastf_t *aabb_min,
67 const fastf_t *aabb_max
68 );
69
70__END_DECLS
71
72#endif /* BG_AABB_RAY_H */
73/** @} */
74/*
75 * Local Variables:
76 * mode: C
77 * tab-width: 8
78 * indent-tabs-mode: t
79 * c-file-style: "stroustrup"
80 * End:
81 * ex: shiftwidth=4 tabstop=8
82 */
Header file for the BRL-CAD common definitions.
int bg_isect_aabb_ray(fastf_t *r_min, fastf_t *r_max, const point_t opt, const fastf_t *invdir, const fastf_t *aabb_min, const fastf_t *aabb_max)
void bg_ray_invdir(vect_t *invdir, const vect_t dir)
Intersection between an infinite line and an axis-aligned box.
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition vmath.h:351
double fastf_t
fastest 64-bit (or larger) floating point type
Definition vmath.h:336
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition vmath.h:357
fundamental vector, matrix, quaternion math macros