source: projectionDesigner/trunk/projdesigner/include/gmtl/RayOps.h @ 373

Last change on this file since 373 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 2.9 KB
RevLine 
[4]1/************************************************************** ggt-head beg
2 *
3 * GGT: Generic Graphics Toolkit
4 *
5 * Original Authors:
6 *   Allen Bierbaum
7 *
8 * -----------------------------------------------------------------
9 * File:          RayOps.h,v
10 * Date modified: 2003/05/10 21:18:01
11 * Version:       1.1
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_RAYOPS_H_
36#define _GMTL_RAYOPS_H_
37
38#include <gmtl/Ray.h>
39
40namespace gmtl {
41
42//--- Ray Comparitor ---//
43/**
44 * Compare two line segments to see if they are EXACTLY the same.
45 *
46 * @param ls1     the first Ray to compare
47 * @param ls2     the second Ray to compare
48 *
49 * @return  true if they are equal, false otherwise
50 */
51template< class DATA_TYPE >
52inline bool operator==( const Ray<DATA_TYPE>& ls1, const Ray<DATA_TYPE>& ls2 )
53{
54   return ( (ls1.mOrigin == ls2.mOrigin) && (ls1.mDir == ls2.mDir) );
55}
56
57/**
58 * Compare two line segments to see if they are not EXACTLY the same.
59 *
60 * @param ls1     the first Ray to compare
61 * @param ls2     the second Ray to compare
62 *
63 * @return  true if they are not equal, false otherwise
64 */
65template< class DATA_TYPE >
66inline bool operator!=( const Ray<DATA_TYPE>& ls1,
67                        const Ray<DATA_TYPE>& ls2 )
68{
69   return ( ! (ls1 == ls2) );
70}
71
72/**
73 * Compare two line segments to see if the are the same within the given
74 * tolerance.
75 *
76 * @param ls1     the first Ray to compare
77 * @param ls2     the second Ray to compare
78 * @param eps     the tolerance value to use
79 *
80 * @pre eps must be >= 0
81 *
82 * @return  true if they are equal within the tolerance, false otherwise
83 */
84template< class DATA_TYPE >
85inline bool isEqual( const Ray<DATA_TYPE>& ls1,
86                     const Ray<DATA_TYPE>& ls2,
87                     const DATA_TYPE& eps )
88{
89   gmtlASSERT( eps >= 0 );
90   return ( (isEqual(ls1.mOrigin, ls2.mOrigin, eps)) &&
91            (isEqual(ls1.mDir, ls2.mDir, eps)) );
92}
93
94} // namespace gmtl
95#endif
Note: See TracBrowser for help on using the repository browser.