00001 /*************************************************************************\ 00002 00003 Copyright 1999 The University of North Carolina at Chapel Hill. 00004 All Rights Reserved. 00005 00006 Permission to use, copy, modify and distribute this software and its 00007 documentation for educational, research and non-profit purposes, without 00008 fee, and without a written agreement is hereby granted, provided that the 00009 above copyright notice and the following three paragraphs appear in all 00010 copies. 00011 00012 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE 00013 LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR 00014 CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE 00015 USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY 00016 OF NORTH CAROLINA HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH 00017 DAMAGES. 00018 00019 THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY 00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 00022 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 00023 NORTH CAROLINA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, 00024 UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 00025 00026 The authors may be contacted via: 00027 00028 US Mail: E. Larsen 00029 Department of Computer Science 00030 Sitterson Hall, CB #3175 00031 University of N. Carolina 00032 Chapel Hill, NC 27599-3175 00033 00034 Phone: (919)962-1749 00035 00036 EMail: geom@cs.unc.edu 00037 00038 00039 \**************************************************************************/ 00040 00041 #ifndef PQP_BV_H 00042 #define PQP_BV_H 00043 00044 #include <math.h> 00045 #include "Tri.h" 00046 #include "PQP_Compile.h" 00047 00048 struct BV 00049 { 00050 PQP_REAL R[3][3]; // orientation of RSS & OBB 00051 00052 #if PQP_BV_TYPE & RSS_TYPE 00053 PQP_REAL Tr[3]; // position of rectangle 00054 PQP_REAL l[2]; // side lengths of rectangle 00055 PQP_REAL r; // radius of sphere summed with rectangle to form RSS 00056 #endif 00057 00058 #if PQP_BV_TYPE & OBB_TYPE 00059 PQP_REAL To[3]; // position of obb 00060 PQP_REAL d[3]; // (half) dimensions of obb 00061 #endif 00062 00063 int first_child; // positive value is index of first_child bv 00064 // negative value is -(index + 1) of triangle 00065 00066 BV(); 00067 ~BV(); 00068 int Leaf() { return first_child < 0; } 00069 PQP_REAL GetSize(); 00070 void FitToTris(PQP_REAL O[3][3], Tri *tris, int num_tris); 00071 }; 00072 00073 inline 00074 PQP_REAL 00075 BV::GetSize() 00076 { 00077 #if PQP_BV_TYPE & RSS_TYPE 00078 return (sqrt(l[0]*l[0] + l[1]*l[1]) + 2*r); 00079 #else 00080 return (d[0]*d[0] + d[1]*d[1] + d[2]*d[2]); 00081 #endif 00082 } 00083 00084 int 00085 BV_Overlap(PQP_REAL R[3][3], PQP_REAL T[3], BV *b1, BV *b2); 00086 00087 #if PQP_BV_TYPE & RSS_TYPE 00088 PQP_REAL 00089 BV_Distance(PQP_REAL R[3][3], PQP_REAL T[3], BV *b1, BV *b2); 00090 #endif 00091 00092 #endif 00093 00094