source: projectionDesigner/tag/ProjectionDesigner_1.1.5/projdesigner/include/gmtl/AABoxOps.h

Last change on this file was 2, checked in by Torben Dannhauer, 14 years ago
File size: 3.2 KB
Line 
1/************************************************************** ggt-head beg
2 *
3 * GGT: Generic Graphics Toolkit
4 *
5 * Original Authors:
6 *   Allen Bierbaum
7 *
8 * -----------------------------------------------------------------
9 * File:          AABoxOps.h,v
10 * Date modified: 2003/03/17 02:14:48
11 * Version:       1.5
12 * -----------------------------------------------------------------
13 *
14 *********************************************************** ggt-head end */
15/*************************************************************** ggt-cpr beg
16*
17* GGT: The Generic Graphics Toolkit
18* Copyright (C) 2001,2002 Allen Bierbaum
19*
20* This library is free software; you can redistribute it and/or
21* modify it under the terms of the GNU Lesser General Public
22* License as published by the Free Software Foundation; either
23* version 2.1 of the License, or (at your option) any later version.
24*
25* This library is distributed in the hope that it will be useful,
26* but WITHOUT ANY WARRANTY; without even the implied warranty of
27* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28* Lesser General Public License for more details.
29*
30* You should have received a copy of the GNU Lesser General Public
31* License along with this library; if not, write to the Free Software
32* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33*
34 ************************************************************ ggt-cpr end */
35#ifndef _GMTL_AABOXOPS_H_
36#define _GMTL_AABOXOPS_H_
37
38#include <gmtl/AABox.h>
39#include <gmtl/VecOps.h>
40
41namespace gmtl
42{
43
44/** @ingroup Compare AABox
45 * @name AABox Comparitors
46 * @{
47 */
48
49/**
50 * Compare two AABoxes to see if they are EXACTLY the same. In other words,
51 * this comparison is done with zero tolerance.
52 *
53 * @param b1      the first box to compare
54 * @param b2      the second box to compare
55 *
56 * @return  true if they are equal, false otherwise
57 */
58template< class DATA_TYPE >
59inline bool operator==( const AABox<DATA_TYPE>& b1, const AABox<DATA_TYPE>& b2 )
60{
61   return ( (b1.isEmpty() == b2.isEmpty()) &&
62            (b1.getMin() == b2.getMin()) &&
63            (b1.getMax() == b2.getMax()) );
64}
65
66/**
67 * Compare two AABoxes to see if they are not EXACTLY the same. In other words,
68 * this comparison is done with zero tolerance.
69 *
70 * @param b1      the first box to compare
71 * @param b2      the second box to compare
72 *
73 * @return  true if they are not equal, false otherwise
74 */
75template< class DATA_TYPE >
76inline bool operator!=( const AABox<DATA_TYPE>& b1, const AABox<DATA_TYPE>& b2 )
77{
78   return (! (b1 == b2));
79}
80
81/**
82 * Compare two AABoxes to see if they are the same within the given tolerance.
83 *
84 * @param b1      the first box to compare
85 * @param b2      the second box to compare
86 * @param eps     the tolerance value to use
87 *
88 * @pre eps must be >= 0
89 *
90 * @return  true if their points are within the given tolerance of each other, false otherwise
91 */
92template< class DATA_TYPE >
93inline bool isEqual( const AABox<DATA_TYPE>& b1, const AABox<DATA_TYPE>& b2, const DATA_TYPE& eps )
94{
95   gmtlASSERT( eps >= 0 );
96   return (b1.isEmpty() == b2.isEmpty()) &&
97          isEqual( b1.getMin(), b2.getMin(), eps ) &&
98          isEqual( b1.getMax(), b2.getMax(), eps );
99}
100/** @} */
101
102}
103
104#endif
105
Note: See TracBrowser for help on using the repository browser.