zenilib: zenilib/jni/external/zenilib/zeni/Zeni/Collision.hxx Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Collision.hxx
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2 * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3 *
4 * zenilib is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * zenilib is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef ZENI_COLLISION_HXX
19 #define ZENI_COLLISION_HXX
20
21 #include <Zeni/Collision.h>
22
23 #include <Zeni/Define.h>
24
25 namespace Zeni {
26
27 namespace Collision {
28
29 float Sphere::shortest_distance(const Plane &rhs) const {
30 return rhs.shortest_distance(*this);
31 }
32 float Sphere::shortest_distance(const Line &rhs) const {
33 return rhs.shortest_distance(*this);
34 }
35 float Sphere::shortest_distance(const Ray &rhs) const {
36 return rhs.shortest_distance(*this);
37 }
38 float Sphere::shortest_distance(const Line_Segment &rhs) const {
39 return rhs.shortest_distance(*this);
40 }
41 float Sphere::shortest_distance(const Infinite_Cylinder &rhs) const {
42 return rhs.shortest_distance(*this);
43 }
44 float Sphere::shortest_distance(const Capsule &rhs) const {
45 return rhs.shortest_distance(*this);
46 }
47 float Sphere::shortest_distance(const Parallelepiped &rhs) const {
48 return rhs.shortest_distance(*this);
49 }
50
51 template <typename TYPE>
52 bool Sphere::intersects(const TYPE &rhs) const {
53 return shortest_distance(rhs) < ZENI_COLLISION_EPSILON;
54 }
55
56 float Plane::shortest_distance(const Line &rhs) const {
57 return rhs.shortest_distance(*this);
58 }
59 float Plane::shortest_distance(const Ray &rhs) const {
60 return rhs.shortest_distance(*this);
61 }
62 float Plane::shortest_distance(const Line_Segment &rhs) const {
63 return rhs.shortest_distance(*this);
64 }
65 float Plane::shortest_distance(const Infinite_Cylinder &rhs) const {
66 return rhs.shortest_distance(*this);
67 }
68 float Plane::shortest_distance(const Capsule &rhs) const {
69 return rhs.shortest_distance(*this);
70 }
71 float Plane::shortest_distance(const Parallelepiped &rhs) const {
72 return rhs.shortest_distance(*this);
73 }
74
75 template <typename TYPE>
76 bool Plane::intersects(const TYPE &rhs) const {
77 return shortest_distance(rhs) < ZENI_COLLISION_EPSILON;
78 }
79
80 float Line_Segment::shortest_distance(const Sphere &rhs) const {
81 return nearest_point(rhs).first;
82 }
83 float Line_Segment::shortest_distance(const Zeni::Point3f &rhs) const {
84 return nearest_point(rhs).first;
85 }
86 float Line_Segment::shortest_distance(const Plane &rhs) const {
87 return nearest_point(rhs).first;
88 }
89 float Line_Segment::shortest_distance(const Line &rhs) const {
90 return nearest_point(rhs).first;
91 }
92 float Line_Segment::shortest_distance(const Ray &rhs) const {
93 return nearest_point(rhs).first;
94 }
95 float Line_Segment::shortest_distance(const Line_Segment &rhs) const {
96 return nearest_point(rhs).first;
97 }
98 float Line_Segment::shortest_distance(const Infinite_Cylinder &rhs) const {
99 return rhs.shortest_distance(*this);
100 }
101 float Line_Segment::shortest_distance(const Capsule &rhs) const {
102 return rhs.shortest_distance(*this);
103 }
104 float Line_Segment::shortest_distance(const Parallelepiped &rhs) const {
105 return nearest_point(rhs).first;
106 }
107
108 template <typename TYPE>
109 bool Line_Segment::intersects(const TYPE &rhs) const {
110 return shortest_distance(rhs) < ZENI_COLLISION_EPSILON;
111 }
112
113 float Ray::shortest_distance(const Sphere &rhs) const {
114 return nearest_point(rhs).first;
115 }
116 float Ray::shortest_distance(const Zeni::Point3f &rhs) const {
117 return nearest_point(rhs).first;
118 }
119 float Ray::shortest_distance(const Plane &rhs) const {
120 return nearest_point(rhs).first;
121 }
122 float Ray::shortest_distance(const Line &rhs) const {
123 return nearest_point(rhs).first;
124 }
125 float Ray::shortest_distance(const Ray &rhs) const {
126 return nearest_point(rhs).first;
127 }
128 float Ray::shortest_distance(const Line_Segment &rhs) const {
129 return nearest_point(rhs).first;
130 }
131 float Ray::shortest_distance(const Infinite_Cylinder &rhs) const {
132 return rhs.shortest_distance(*this);
133 }
134 float Ray::shortest_distance(const Capsule &rhs) const {
135 return rhs.shortest_distance(*this);
136 }
137 float Ray::shortest_distance(const Parallelepiped &rhs) const {
138 return nearest_point(rhs).first;
139 }
140
141 template <typename TYPE>
142 bool Ray::intersects(const TYPE &rhs) const {
143 return shortest_distance(rhs) < ZENI_COLLISION_EPSILON;
144 }
145
146 float Line::shortest_distance(const Ray &rhs) const {
147 return rhs.shortest_distance(*this);
148 }
149 float Line::shortest_distance(const Infinite_Cylinder &rhs) const {
150 return rhs.shortest_distance(*this);
151 }
152 float Line::shortest_distance(const Capsule &rhs) const {
153 return rhs.shortest_distance(*this);
154 }
155
156 template <typename TYPE>
157 bool Line::intersects(const TYPE &rhs) const {
158 return shortest_distance(rhs) < ZENI_COLLISION_EPSILON;
159 }
160
161 float Infinite_Cylinder::shortest_distance(const Capsule &rhs) const {
162 return rhs.shortest_distance(*this);
163 }
164 float Infinite_Cylinder::shortest_distance(const Parallelepiped &rhs) const {
165 return rhs.shortest_distance(*this);
166 }
167
168 template <typename TYPE>
169 bool Infinite_Cylinder::intersects(const TYPE &rhs) const {
170 return shortest_distance(rhs) < ZENI_COLLISION_EPSILON;
171 }
172
173 float Capsule::shortest_distance(const Sphere &rhs) const {
174 return nearest_point(rhs).first;
175 }
176 float Capsule::shortest_distance(const Zeni::Point3f &rhs) const {
177 return nearest_point(rhs).first;
178 }
179 float Capsule::shortest_distance(const Plane &rhs) const {
180 return nearest_point(rhs).first;
181 }
182 float Capsule::shortest_distance(const Line &rhs) const {
183 return nearest_point(rhs).first;
184 }
185 float Capsule::shortest_distance(const Ray &rhs) const {
186 return nearest_point(rhs).first;
187 }
188 float Capsule::shortest_distance(const Line_Segment &rhs) const {
189 return nearest_point(rhs).first;
190 }
191 float Capsule::shortest_distance(const Infinite_Cylinder &rhs) const {
192 return nearest_point(rhs).first;
193 }
194 float Capsule::shortest_distance(const Capsule &rhs) const {
195 return nearest_point(rhs).first;
196 }
197 float Capsule::shortest_distance(const Parallelepiped &rhs) const {
198 return nearest_point(rhs).first;
199 }
200
201 template <typename TYPE>
202 bool Capsule::intersects(const TYPE &rhs) const {
203 return shortest_distance(rhs) < ZENI_COLLISION_EPSILON;
204 }
205
206 float Parallelepiped::shortest_distance(const Line &rhs) const {
207 return rhs.shortest_distance(*this);
208 }
209 float Parallelepiped::shortest_distance(const Ray &rhs) const {
210 return rhs.shortest_distance(*this);
211 }
212 float Parallelepiped::shortest_distance(const Line_Segment &rhs) const {
213 return rhs.shortest_distance(*this);
214 }
215 float Parallelepiped::shortest_distance(const Capsule &rhs) const {
216 return rhs.shortest_distance(*this);
217 }
218
219 template <typename TYPE>
220 bool Parallelepiped::intersects(const TYPE &rhs) const {
221 return shortest_distance(rhs) < ZENI_COLLISION_EPSILON;
222 }
223
224 template <>
225 inline bool Parallelepiped::intersects<Parallelepiped>(const Parallelepiped &rhs) const {
226 return some_distance(rhs) < ZENI_COLLISION_EPSILON;
227 }
228
229 }
230
231 }
232
233 #include <Zeni/Undefine.h>
234
235 #endif
Zeni::Collision::Plane::shortest_distance
float shortest_distance(const Plane &rhs) const
Definition: Collision.cpp:275
Zeni::Collision::Capsule::intersects
bool intersects(const TYPE &rhs) const
Definition: Collision.hxx:202
Zeni::Collision::Capsule
Collision Capsule.
Definition: Collision.h:382
Zeni::Collision::Line
Collision Line.
Definition: Collision.h:318
ZENI_COLLISION_EPSILON
#define ZENI_COLLISION_EPSILON
Definition: Define.h:79
Zeni::Collision::Plane::intersects
bool intersects(const TYPE &rhs) const
Definition: Collision.hxx:76
Undefine.h
Zeni::Collision::Line::shortest_distance
float shortest_distance(const Line &rhs) const
Definition: Collision.cpp:316
Zeni::Collision::Infinite_Cylinder::shortest_distance
float shortest_distance(const Infinite_Cylinder &rhs) const
Definition: Collision.cpp:417
Zeni::Collision::Capsule::nearest_point
std::pair< float, float > nearest_point(const Capsule &rhs) const
Returns &lt;distance, interpolation value [0.0f, 1.0f]&gt;
Definition: Collision.cpp:458
Zeni::Collision::Sphere::shortest_distance
float shortest_distance(const Sphere &rhs) const
Definition: Collision.cpp:262
Zeni::Collision::Line_Segment
Collision Line Segment.
Definition: Collision.h:233
Zeni::Collision::Infinite_Cylinder
Collision Infinite Cylinder.
Definition: Collision.h:352
Zeni::Point3f
A 3D Point represented with floats.
Definition: Coordinate.h:133
Zeni::Collision::Capsule::shortest_distance
float shortest_distance(const Capsule &rhs) const
Definition: Collision.hxx:194
Collision.h
Zeni::Collision::Sphere::intersects
bool intersects(const TYPE &rhs) const
Definition: Collision.hxx:52
Define.h
Zeni::Collision::Sphere
Collision Sphere.
Definition: Collision.h:181
Zeni::Collision::Ray::intersects
bool intersects(const TYPE &rhs) const
Definition: Collision.hxx:142
Zeni::Collision::Parallelepiped
Collision Parallelepiped.
Definition: Collision.h:421
Zeni::Collision::Line_Segment::shortest_distance
float shortest_distance(const Sphere &rhs) const
Definition: Collision.hxx:80
Zeni::Collision::Ray
Collision Ray.
Definition: Collision.h:275
Zeni::Collision::Parallelepiped::intersects
bool intersects(const TYPE &rhs) const
Definition: Collision.hxx:220
Zeni::Collision::Parallelepiped::shortest_distance
float shortest_distance(const Parallelepiped &rhs) const
Definition: Collision.cpp:495
Zeni::Collision::Plane
Collision Plane.
Definition: Collision.h:207
Zeni::Collision::Line_Segment::nearest_point
std::pair< float, float > nearest_point(const Line_Segment &rhs) const
Returns &lt;distance, interpolation value [0.0f, 1.0f]&gt;
Definition: Collision.cpp:387
Zeni::Collision::Ray::shortest_distance
float shortest_distance(const Sphere &rhs) const
Definition: Collision.hxx:113
Zeni::Collision::Infinite_Cylinder::intersects
bool intersects(const TYPE &rhs) const
Definition: Collision.hxx:169
TYPE
Definition: infutil.h:15
Zeni::Collision::Ray::nearest_point
std::pair< float, float > nearest_point(const Ray &rhs) const
Returns &lt;distance, interpolation value [0.0f, inf)&gt;
Definition: Collision.cpp:354
Zeni::Collision::Line::intersects
bool intersects(const TYPE &rhs) const
Definition: Collision.hxx:157
Zeni::Collision::Line_Segment::intersects
bool intersects(const TYPE &rhs) const
Definition: Collision.hxx:109