wfmath 1.0.3
A math library for the Worldforge system.
intersect_decls.h
1// intersect_decls.h (Declarations for "friend" intersection functions)
2//
3// The WorldForge Project
4// Copyright (C) 2002 The WorldForge Project
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19//
20// For information about WorldForge and its authors, please contact
21// the Worldforge Web Site at http://www.worldforge.org.
22//
23
24// Author: Ron Steinke
25
26#ifndef WFMATH_INTERSECT_DECLS_H
27#define WFMATH_INTERSECT_DECLS_H
28
29#include <wfmath/const.h>
30
31namespace WFMath {
32
33// Some Intersect and Contains helper functions
34
35inline bool _Less(CoordType x1, CoordType x2, bool proper)
36{
37 return proper ? x1 <= x2 : (x2 - x1) > numeric_constants<CoordType>::epsilon();
38}
39
40inline bool _LessEq(CoordType x1, CoordType x2, bool proper)
41{
42 return !proper ? x1 <= x2 : x1 < x2;
43}
44
45inline bool _Greater(CoordType x1, CoordType x2, bool proper)
46{
47 return proper ? x1 >= x2 : (x1 - x2) > numeric_constants<CoordType>::epsilon();
48}
49
50inline bool _GreaterEq(CoordType x1, CoordType x2, bool proper)
51{
52 return !proper ? x1 >= x2 : x1 > x2;
53}
54
55template<int dim>
56bool Intersect(const AxisBox<dim>& b, const Point<dim>& p, bool proper);
57template<int dim>
58bool Contains(const Point<dim>& p, const AxisBox<dim>& b, bool proper);
59
60template<int dim>
61bool Intersect(const Ball<dim>& b, const Point<dim>& p, bool proper);
62template<int dim>
63bool Contains(const Point<dim>& p, const Ball<dim>& b, bool proper);
64
65template<int dim>
66bool Intersect(const Segment<dim>& s, const Point<dim>& p, bool proper);
67template<int dim>
68bool Contains(const Point<dim>& p, const Segment<dim>& s, bool proper);
69
70template<int dim>
71bool Intersect(const RotBox<dim>& r, const Point<dim>& p, bool proper);
72template<int dim>
73bool Contains(const Point<dim>& p, const RotBox<dim>& r, bool proper);
74
75template<int dim>
76bool Intersect(const AxisBox<dim>& b1, const AxisBox<dim>& b2, bool proper);
77template<int dim>
78bool Contains(const AxisBox<dim>& outer, const AxisBox<dim>& inner, bool proper);
79
80template<int dim>
81bool Intersect(const Ball<dim>& b, const AxisBox<dim>& a, bool proper);
82template<int dim>
83bool Contains(const Ball<dim>& b, const AxisBox<dim>& a, bool proper);
84template<int dim>
85bool Contains(const AxisBox<dim>& a, const Ball<dim>& b, bool proper);
86
87template<int dim>
88bool Intersect(const Segment<dim>& s, const AxisBox<dim>& b, bool proper);
89template<int dim>
90bool Contains(const Segment<dim>& s, const AxisBox<dim>& b, bool proper);
91template<int dim>
92bool Contains(const AxisBox<dim>& b, const Segment<dim>& s, bool proper);
93
94template<int dim>
95bool Intersect(const RotBox<dim>& r, const AxisBox<dim>& b, bool proper);
96template<int dim>
97bool Contains(const RotBox<dim>& r, const AxisBox<dim>& b, bool proper);
98template<int dim>
99bool Contains(const AxisBox<dim>& b, const RotBox<dim>& r, bool proper);
100
101template<int dim>
102bool Intersect(const Ball<dim>& b1, const Ball<dim>& b2, bool proper);
103template<int dim>
104bool Contains(const Ball<dim>& outer, const Ball<dim>& inner, bool proper);
105
106template<int dim>
107bool Intersect(const Segment<dim>& s, const Ball<dim>& b, bool proper);
108template<int dim>
109bool Contains(const Ball<dim>& b, const Segment<dim>& s, bool proper);
110template<int dim>
111bool Contains(const Segment<dim>& s, const Ball<dim>& b, bool proper);
112
113template<int dim>
114bool Intersect(const RotBox<dim>& r, const Ball<dim>& b, bool proper);
115template<int dim>
116bool Contains(const RotBox<dim>& r, const Ball<dim>& b, bool proper);
117template<int dim>
118bool Contains(const Ball<dim>& b, const RotBox<dim>& r, bool proper);
119
120template<int dim>
121bool Intersect(const Segment<dim>& s1, const Segment<dim>& s2, bool proper);
122template<int dim>
123bool Contains(const Segment<dim>& s1, const Segment<dim>& s2, bool proper);
124
125template<int dim>
126bool Intersect(const RotBox<dim>& r, const Segment<dim>& s, bool proper);
127template<int dim>
128bool Contains(const RotBox<dim>& r, const Segment<dim>& s, bool proper);
129template<int dim>
130bool Contains(const Segment<dim>& s, const RotBox<dim>& r, bool proper);
131
132template<int dim>
133bool Intersect(const RotBox<dim>& r1, const RotBox<dim>& r2, bool proper);
134template<int dim>
135bool Contains(const RotBox<dim>& outer, const RotBox<dim>& inner, bool proper);
136
137template<int dim>
138bool Intersect(const Polygon<dim>& r, const Point<dim>& p, bool proper);
139template<int dim>
140bool Contains(const Point<dim>& p, const Polygon<dim>& r, bool proper);
141
142template<int dim>
143bool Intersect(const Polygon<dim>& p, const AxisBox<dim>& b, bool proper);
144template<int dim>
145bool Contains(const Polygon<dim>& p, const AxisBox<dim>& b, bool proper);
146template<int dim>
147bool Contains(const AxisBox<dim>& b, const Polygon<dim>& p, bool proper);
148
149template<int dim>
150bool Intersect(const Polygon<dim>& p, const Ball<dim>& b, bool proper);
151template<int dim>
152bool Contains(const Polygon<dim>& p, const Ball<dim>& b, bool proper);
153template<int dim>
154bool Contains(const Ball<dim>& b, const Polygon<dim>& p, bool proper);
155
156template<int dim>
157bool Intersect(const Polygon<dim>& p, const Segment<dim>& s, bool proper);
158template<int dim>
159bool Contains(const Polygon<dim>& p, const Segment<dim>& s, bool proper);
160template<int dim>
161bool Contains(const Segment<dim>& s, const Polygon<dim>& p, bool proper);
162
163template<int dim>
164bool Intersect(const Polygon<dim>& p, const RotBox<dim>& r, bool proper);
165template<int dim>
166bool Contains(const Polygon<dim>& p, const RotBox<dim>& r, bool proper);
167template<int dim>
168bool Contains(const RotBox<dim>& r, const Polygon<dim>& p, bool proper);
169
170template<int dim>
171bool Intersect(const Polygon<dim>& p1, const Polygon<dim>& p2, bool proper);
172template<int dim>
173bool Contains(const Polygon<dim>& outer, const Polygon<dim>& inner, bool proper);
174
175} // namespace WFMath
176
177#endif // WFMATH_INTERSECT_DECLS_H
Generic library namespace.
Definition: shape.h:41
double CoordType
Basic floating point type.
Definition: const.h:140
static FloatType epsilon()
This is the attempted precision of the library.