source: projectionDesigner/trunk/projdesigner/include/gmtl/AxisAngleOps.h @ 238

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