source: projectionDesigner/trunk/projdesigner/include/gmtl/EulerAngleOps.h @ 206

Last change on this file since 206 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 3.4 KB
Line 
1/************************************************************** ggt-head beg
2 *
3 * GGT: Generic Graphics Toolkit
4 *
5 * Original Authors:
6 *   Allen Bierbaum
7 *
8 * -----------------------------------------------------------------
9 * File:          EulerAngleOps.h,v
10 * Date modified: 2004/05/25 16:36:28
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_EULER_ANGLE_OPS_H_
36#define _GMTL_EULER_ANGLE_OPS_H_
37
38#include <gmtl/EulerAngle.h>
39
40namespace gmtl
41{
42
43/** @ingroup Compare
44 *  @name EulerAngle Comparitors
45 *  @{
46 */
47
48/**
49 * Compares 2 EulerAngles (component-wise) to see if they are exactly the same.
50 *
51 * @param e1   the first EulerAngle
52 * @param e2   the second EulerAngle
53 *
54 * @return  true if e1 equals e2; false if they differ
55 */
56template<class DATA_TYPE, typename ROT_ORDER>
57inline bool operator==(const EulerAngle<DATA_TYPE, ROT_ORDER>& e1,
58                       const EulerAngle<DATA_TYPE, ROT_ORDER>& e2)
59{
60   // @todo metaprogramming.
61   if (e1[0] != e2[0]) return false;
62   if (e1[1] != e2[1]) return false;
63   if (e1[2] != e2[2]) return false;
64   return true;
65}
66
67/**
68 * Compares e1 and e2 (component-wise) to see if they are NOT exactly the same.
69 *
70 * @param e1   the first EulerAngle
71 * @param e2   the second EulerAngle
72 *
73 * @return  true if e1 does not equal e2; false if they are equal
74 */
75template<class DATA_TYPE, typename ROT_ORDER>
76inline bool operator!=(const EulerAngle<DATA_TYPE, ROT_ORDER>& e1,
77                       const EulerAngle<DATA_TYPE, ROT_ORDER>& e2)
78{
79   return(! (e1 == e2));
80}
81
82/**
83 * Compares e1 and e2 (component-wise) to see if they are the same within a
84 * given tolerance.
85 *
86 * @pre eps must be >= 0
87 *
88 * @param e1   the first EulerAngle
89 * @param e2   the second EulerAngle
90 * @param eps  the epsilon tolerance value, in radians
91 *
92 * @return  true if e1 is within the tolerance of e2; false if not
93 */
94template<class DATA_TYPE, typename ROT_ORDER>
95inline bool isEqual( const EulerAngle<DATA_TYPE, ROT_ORDER>& e1,
96                     const EulerAngle<DATA_TYPE, ROT_ORDER>& e2,
97                     const DATA_TYPE eps = 0 )
98{
99   gmtlASSERT(eps >= (DATA_TYPE)0);
100   
101   // @todo metaprogramming.
102   if (!Math::isEqual( e1[0], e2[0], eps )) return false;
103   if (!Math::isEqual( e1[1], e2[1], eps )) return false;
104   if (!Math::isEqual( e1[2], e2[2], eps )) return false;
105   return true;
106}
107
108// @todo write isEquiv function for EulerAngle
109
110
111/** @} */
112
113} // namespace
114
115#endif
Note: See TracBrowser for help on using the repository browser.