pqp
 All Classes
BV.h
1 /*************************************************************************\
2 
3  Copyright 1999 The University of North Carolina at Chapel Hill.
4  All Rights Reserved.
5 
6  Permission to use, copy, modify and distribute this software and its
7  documentation for educational, research and non-profit purposes, without
8  fee, and without a written agreement is hereby granted, provided that the
9  above copyright notice and the following three paragraphs appear in all
10  copies.
11 
12  IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE
13  LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
14  CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE
15  USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
16  OF NORTH CAROLINA HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  DAMAGES.
18 
19  THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY
20  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
22  PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
23  NORTH CAROLINA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
24  UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 
26  The authors may be contacted via:
27 
28  US Mail: E. Larsen
29  Department of Computer Science
30  Sitterson Hall, CB #3175
31  University of N. Carolina
32  Chapel Hill, NC 27599-3175
33 
34  Phone: (919)962-1749
35 
36  EMail: geom@cs.unc.edu
37 
38 
39 \**************************************************************************/
40 
41 #ifndef PQP_BV_H
42 #define PQP_BV_H
43 
44 #include <math.h>
45 #include "Tri.h"
46 #include "PQP_Compile.h"
47 
48 struct BV
49 {
50  PQP_REAL R[3][3]; // orientation of RSS & OBB
51 
52 #if PQP_BV_TYPE & RSS_TYPE
53  PQP_REAL Tr[3]; // position of rectangle
54  PQP_REAL l[2]; // side lengths of rectangle
55  PQP_REAL r; // radius of sphere summed with rectangle to form RSS
56 #endif
57 
58 #if PQP_BV_TYPE & OBB_TYPE
59  PQP_REAL To[3]; // position of obb
60  PQP_REAL d[3]; // (half) dimensions of obb
61 #endif
62 
63  int first_child; // positive value is index of first_child bv
64  // negative value is -(index + 1) of triangle
65 
66  BV();
67  ~BV();
68  int Leaf() { return first_child < 0; }
69  PQP_REAL GetSize();
70  void FitToTris(PQP_REAL O[3][3], Tri *tris, int num_tris);
71 };
72 
73 inline
74 PQP_REAL
75 BV::GetSize()
76 {
77 #if PQP_BV_TYPE & RSS_TYPE
78  return (sqrt(l[0]*l[0] + l[1]*l[1]) + 2*r);
79 #else
80  return (d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
81 #endif
82 }
83 
84 int
85 BV_Overlap(PQP_REAL R[3][3], PQP_REAL T[3], BV *b1, BV *b2);
86 
87 #if PQP_BV_TYPE & RSS_TYPE
88 PQP_REAL
89 BV_Distance(PQP_REAL R[3][3], PQP_REAL T[3], BV *b1, BV *b2);
90 #endif
91 
92 #endif
93 
94