1 | /************************************************************** ggt-head beg |
---|
2 | * |
---|
3 | * GGT: Generic Graphics Toolkit |
---|
4 | * |
---|
5 | * Original Authors: |
---|
6 | * Allen Bierbaum |
---|
7 | * |
---|
8 | * ----------------------------------------------------------------- |
---|
9 | * File: CoordOps.h,v |
---|
10 | * Date modified: 2004/05/25 16:36:28 |
---|
11 | * Version: 1.6 |
---|
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_COORD_OPS_H_ |
---|
36 | #define _GMTL_COORD_OPS_H_ |
---|
37 | |
---|
38 | #include <gmtl/Coord.h> |
---|
39 | |
---|
40 | namespace gmtl |
---|
41 | { |
---|
42 | /** @ingroup Compare Coord |
---|
43 | * @name Coord Comparitors |
---|
44 | * @{ |
---|
45 | */ |
---|
46 | |
---|
47 | /** Compare two coordinate frames for equality. |
---|
48 | * @param c1 the first Coord |
---|
49 | * @param c2 the second Coord |
---|
50 | * @return true if c1 is the same as c2, false otherwise |
---|
51 | */ |
---|
52 | template <typename POS_TYPE, typename ROT_TYPE> |
---|
53 | inline bool operator==( const Coord<POS_TYPE, ROT_TYPE>& c1, |
---|
54 | const Coord<POS_TYPE, ROT_TYPE>& c2 ) |
---|
55 | { |
---|
56 | return bool( c1.getPos() == c2.getPos() && |
---|
57 | c1.getRot() == c2.getRot() ); |
---|
58 | } |
---|
59 | |
---|
60 | /** Compare two coordinate frames for not-equality. |
---|
61 | * @param c1 the first Coord |
---|
62 | * @param c2 the second Coord |
---|
63 | * @return true if c1 is different from c2, false otherwise |
---|
64 | */ |
---|
65 | template <typename POS_TYPE, typename ROT_TYPE> |
---|
66 | inline bool operator!=( const Coord<POS_TYPE, ROT_TYPE>& c1, |
---|
67 | const Coord<POS_TYPE, ROT_TYPE>& c2 ) |
---|
68 | { |
---|
69 | return !operator==( c1, c2 ); |
---|
70 | } |
---|
71 | |
---|
72 | /** Compare two coordinate frames for equality with a given tolerance. |
---|
73 | * @param c1 the first Coord |
---|
74 | * @param c2 the second Coord |
---|
75 | * @param tol the tolerance coordinate frame of the same type as c1 and c2 |
---|
76 | * @return true if c1 is equal within a tolerance of c2, false otherwise |
---|
77 | */ |
---|
78 | template <typename POS_TYPE, typename ROT_TYPE> |
---|
79 | inline bool isEqual( const Coord<POS_TYPE, ROT_TYPE>& c1, |
---|
80 | const Coord<POS_TYPE, ROT_TYPE>& c2, |
---|
81 | typename Coord<POS_TYPE, ROT_TYPE>::DataType tol = 0 ) |
---|
82 | { |
---|
83 | return bool( isEqual( c1.getPos(), c2.getPos(), tol ) && |
---|
84 | isEqual( c1.getRot(), c2.getRot(), tol ) ); |
---|
85 | } |
---|
86 | /** @} */ |
---|
87 | |
---|
88 | } |
---|
89 | |
---|
90 | #endif |
---|