BRL-CAD
Loading...
Searching...
No Matches
obr.h
Go to the documentation of this file.
1/* O B R . 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 obr.h */
23/** @addtogroup bg_obr */
24/** @{ */
25
26/**
27 * @brief Routines for the computation of oriented bounding rectangles 2D and 3D
28 */
29
30#ifndef BG_OBR_H
31#define BG_OBR_H
32
33#include "common.h"
34#include "vmath.h"
35#include "bg/defines.h"
36
37__BEGIN_DECLS
38
39/**
40 *@brief
41 * Uses the Rotating Calipers algorithm to find the
42 * minimum oriented bounding rectangle for a set of 2D
43 * points. Returns 0 on success.
44 *
45 * The box will be described by a center point and 2
46 * vectors:
47 *
48 * \verbatim
49 * ----------------------------
50 * | ^ |
51 * | | |
52 * | v | |
53 * | | |
54 * | *------------>|
55 * | center u |
56 * | |
57 * | |
58 * ----------------------------
59 * \endverbatim
60 *
61 * Note that the box is oriented, and thus not necessarily axis
62 * aligned (u and v are perpendicular, but not necessarily parallel
63 * with the coordinate space V=0 and U=0 axis vectors.)
64 *
65 * @param[out] center center of oriented bounding rectangle
66 * @param[out] u vector in the direction of obr x with
67 * vector length of 0.5 * obr length
68 * @param[out] v vector in the obr y direction with vector
69 * length of 0.5 * obr width
70 * @param points_2d array of 2D points
71 * @param pnt_cnt number of points in pnts array
72 */
73BG_EXPORT extern int bg_2d_obr(point2d_t *center,
74 vect2d_t *u,
75 vect2d_t *v,
76 const point2d_t *points_2d,
77 int pnt_cnt);
78
79/**
80 *@brief
81 * Uses the Rotating Calipers algorithm to find the
82 * minimum oriented bounding rectangle for a set of coplanar 3D
83 * points. Returns 0 on success.
84 *
85 * @param[out] center center of oriented bounding rectangle
86 * @param[out] v1 vector in the direction of obr x with
87 * vector length of 0.5 * obr length
88 * @param[out] v2 vector in the obr y direction with vector
89 * length of 0.5 * obr width
90 * @param points_3d array of coplanar 3D points
91 * @param pnt_cnt number of points in pnts array
92 */
93BG_EXPORT extern int bg_3d_coplanar_obr(point_t *center,
94 vect_t *v1,
95 vect_t *v2,
96 const point_t *points_3d,
97 int pnt_cnt);
98
99/**
100 *@brief
101 * Find an oriented bounding rectangular cuboid for a set of 3D points using
102 * the point-set orientation and containment fit. Returns 0 on success.
103 *
104 * The points in the output array are arranged as seen
105 * in the figure below, with the integer number at each
106 * vertex position corresponding to the pnts array index
107 * n-1 (for example, the first point, labeled 1 below,
108 * would be pnts[0].)
109 *
110 * \verbatim
111 * 8
112 * * | *
113 * * | *
114 * 4 | 7
115 * | * | * |
116 * | * * |
117 * | | 3 |
118 * | | | |
119 * | 5 | |
120 * | * |* |
121 * | * | * |
122 * 1 | 6
123 * * | *
124 * * | *
125 * 2
126 * \endverbatim
127 *
128 *
129 * @param[out] pnts eight points of oriented bounding box
130 * @param points_3d array of 3D points
131 * @param pnt_cnt number of points in pnts array
132 */
133BG_EXPORT extern int bg_3d_obb(point_t **pnts,
134 const fastf_t *points_3d,
135 int pnt_cnt);
136
137
138__END_DECLS
139
140#endif /* BG_OBR_H */
141/** @} */
142/*
143 * Local Variables:
144 * mode: C
145 * tab-width: 8
146 * indent-tabs-mode: t
147 * c-file-style: "stroustrup"
148 * End:
149 * ex: shiftwidth=4 tabstop=8
150 */
Header file for the BRL-CAD common definitions.
int bg_3d_obb(point_t **pnts, const fastf_t *points_3d, int pnt_cnt)
Find an oriented bounding rectangular cuboid for a set of 3D points using the point-set orientation a...
int bg_2d_obr(point2d_t *center, vect2d_t *u, vect2d_t *v, const point2d_t *points_2d, int pnt_cnt)
Routines for the computation of oriented bounding rectangles 2D and 3D.
int bg_3d_coplanar_obr(point_t *center, vect_t *v1, vect_t *v2, const point_t *points_3d, int pnt_cnt)
Uses the Rotating Calipers algorithm to find the minimum oriented bounding rectangle for a set of cop...
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 point2d_t[ELEMENTS_PER_POINT2D]
2-tuple point
Definition vmath.h:345
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition vmath.h:357
fastf_t vect2d_t[ELEMENTS_PER_VECT2D]
2-tuple vector
Definition vmath.h:339
fundamental vector, matrix, quaternion math macros