Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
predicates/kernel_ftC3.h
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Copyright (c) 2000 The CGAL Consortium
4 
5 // This software and related documentation is part of the Computational
6 // Geometry Algorithms Library (CGAL).
7 // This software and documentation is provided "as-is" and without warranty
8 // of any kind. In no event shall the CGAL Consortium be liable for any
9 // damage of any kind.
10 //
11 // Every use of CGAL requires a license.
12 //
13 // Academic research and teaching license
14 // - For academic research and teaching purposes, permission to use and copy
15 // the software and its documentation is hereby granted free of charge,
16 // provided that it is not a component of a commercial product, and this
17 // notice appears in all copies of the software and related documentation.
18 //
19 // Commercial licenses
20 // - A commercial license is available through Algorithmic Solutions, who also
21 // markets LEDA (http://www.algorithmic-solutions.de).
22 // - Commercial users may apply for an evaluation license by writing to
23 // Algorithmic Solutions (contact@algorithmic-solutions.com).
24 //
25 // The CGAL Consortium consists of Utrecht University (The Netherlands),
26 // ETH Zurich (Switzerland), Free University of Berlin (Germany),
27 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
28 // (Germany), Max-Planck-Institute Saarbrucken (Germany), RISC Linz (Austria),
29 // and Tel-Aviv University (Israel).
30 //
31 // ----------------------------------------------------------------------
32 //
33 // release : CGAL-2.2
34 // release_date : 2000, September 30
35 //
36 // file : include/CGAL/predicates/kernel_ftC3.h
37 // package : C3 (5.2)
38 // revision : $Revision: 1.1.1.1 $
39 // revision_date : $Date: 2001/07/05 22:17:49 $
40 // author(s) : Herve Bronnimann, Sylvain Pion
41 // coordinator : INRIA Sophia-Antipolis
42 //
43 // email : contact@cgal.org
44 // www : http://www.cgal.org
45 //
46 // ======================================================================
47 
48 #ifndef CGAL_PREDICATES_KERNEL_FTC3_H
49 #define CGAL_PREDICATES_KERNEL_FTC3_H
50 
54 
56 
57 template < class FT >
58 /*CGAL_NO_FILTER*/
61 compare_lexicographically_xyzC3(const FT &px, const FT &py, const FT &pz,
62  const FT &qx, const FT &qy, const FT &qz)
63 {
65  if (c != EQUAL) return c;
66  c = CGAL_NTS compare(py, qy);
67  if (c != EQUAL) return c;
68  return CGAL_NTS compare(pz, qz);
69 }
70 
71 template < class FT >
73 bool
74 strict_dominanceC3(const FT &px, const FT &py, const FT &pz,
75  const FT &qx, const FT &qy, const FT &qz)
76 {
77  return CGAL_NTS compare(px, qx) == LARGER &&
78  CGAL_NTS compare(py, qy) == LARGER &&
79  CGAL_NTS compare(pz, qz) == LARGER;
80 }
81 
82 template < class FT >
84 bool
85 dominanceC3(const FT &px, const FT &py, const FT &pz,
86  const FT &qx, const FT &qy, const FT &qz)
87 {
88  return CGAL_NTS compare(px, qx) != SMALLER &&
89  CGAL_NTS compare(py, qy) != SMALLER &&
90  CGAL_NTS compare(pz, qz) != SMALLER;
91 }
92 
93 template < class FT >
95 bool
96 collinearC3(const FT &px, const FT &py, const FT &pz,
97  const FT &qx, const FT &qy, const FT &qz,
98  const FT &rx, const FT &ry, const FT &rz)
99 {
100  FT dpx = px-rx;
101  FT dqx = qx-rx;
102  FT dpy = py-ry;
103  FT dqy = qy-ry;
104  if (sign_of_determinant2x2(dpx, dqx, dpy, dqy) != ZERO)
105  return false;
106  FT dpz = pz-rz;
107  FT dqz = qz-rz;
108  return sign_of_determinant2x2(dpx, dqx, dpz, dqz) == ZERO
109  && sign_of_determinant2x2(dpy, dqy, dpz, dqz) == ZERO;
110 }
111 
112 template < class FT >
115 orientationC3(const FT &px, const FT &py, const FT &pz,
116  const FT &qx, const FT &qy, const FT &qz,
117  const FT &rx, const FT &ry, const FT &rz,
118  const FT &sx, const FT &sy, const FT &sz)
119 {
120  return Orientation(sign_of_determinant3x3(qx-px,rx-px,sx-px,
121  qy-py,ry-py,sy-py,
122  qz-pz,rz-pz,sz-pz));
123 }
124 
125 template < class FT >
126 /*CGAL_NO_FILTER*/
129 coplanar_orientationC3(const FT &qx, const FT &qy, const FT &qz,
130  const FT &rx, const FT &ry, const FT &rz,
131  const FT &sx, const FT &sy, const FT &sz,
132  const FT &px, const FT &py, const FT &pz)
133 {
134  Orientation oxy_qrs = orientationC2(qx,qy,rx,ry,sx,sy);
135  if (oxy_qrs != COLLINEAR)
136  return Orientation( oxy_qrs * orientationC2(qx,qy,rx,ry,px,py));
137  Orientation oyz_qrs = orientationC2(qy,qz,ry,rz,sy,sz);
138  if (oyz_qrs != COLLINEAR)
139  return Orientation( oyz_qrs * orientationC2(qy,qz,ry,rz,py,pz));
140  Orientation oxz_qrs = orientationC2(qx,qz,rx,rz,sx,sz);
141  assert(oxz_qrs != COLLINEAR);
142  return Orientation( oxz_qrs * orientationC2(qx,qz,rx,rz,px,pz));
143 }
144 
145 template < class FT >
146 /*CGAL_NO_FILTER*/
148 bool
150  const FT &px, const FT &py, const FT &pz,
151  const FT &qx, const FT &qy, const FT &qz,
152  const FT &rx, const FT &ry, const FT &rz)
153 {
154  if (px < qx) return !(rx < qx);
155  if (qx < px) return !(qx < rx);
156  if (py < qy) return !(ry < qy);
157  if (qy < py) return !(qy < ry);
158  if (pz < qz) return !(rz < qz);
159  if (qz < pz) return !(qz < rz);
160  return true; // p==q
161 }
162 
163 template < class FT >
164 /*CGAL_NO_FILTER*/
166 bool
168  const FT &px, const FT &py, const FT &pz,
169  const FT &qx, const FT &qy, const FT &qz,
170  const FT &rx, const FT &ry, const FT &rz)
171 {
172  if (px < qx) return (qx < rx);
173  if (qx < px) return (rx < qx);
174  if (py < qy) return (qy < ry);
175  if (qy < py) return (ry < qy);
176  if (pz < qz) return (qz < rz);
177  if (qz < pz) return (rz < qz);
178  return false; // p==q
179 }
180 
181 template < class FT >
183 bool
184 equal_directionC3(const FT &dx1, const FT &dy1, const FT &dz1,
185  const FT &dx2, const FT &dy2, const FT &dz2)
186 {
187  return sign_of_determinant2x2(dx1, dy1, dx2, dy2) == ZERO
188  && sign_of_determinant2x2(dx1, dz1, dx2, dz2) == ZERO
189  && sign_of_determinant2x2(dy1, dz1, dy2, dz2) == ZERO
190  && CGAL_NTS sign(dx1) == CGAL_NTS sign(dx2)
191  && CGAL_NTS sign(dy1) == CGAL_NTS sign(dy2)
192  && CGAL_NTS sign(dz1) == CGAL_NTS sign(dz2);
193 }
194 
195 template <class FT >
198 side_of_oriented_planeC3(const FT &a, const FT &b, const FT &c, const FT &d,
199  const FT &px, const FT &py, const FT &pz)
200 {
201  return Oriented_side(CGAL_NTS sign(a*px + b*py + c*pz +d));
202 }
203 
204 template <class FT >
207 side_of_oriented_sphereC3(const FT &px, const FT &py, const FT &pz,
208  const FT &qx, const FT &qy, const FT &qz,
209  const FT &rx, const FT &ry, const FT &rz,
210  const FT &sx, const FT &sy, const FT &sz,
211  const FT &tx, const FT &ty, const FT &tz)
212 {
213  FT ptx = px - tx;
214  FT pty = py - ty;
215  FT ptz = pz - tz;
216  FT pt2 = CGAL_NTS square(ptx) + CGAL_NTS square(pty) + CGAL_NTS square(ptz);
217  FT qtx = qx - tx;
218  FT qty = qy - ty;
219  FT qtz = qz - tz;
220  FT qt2 = CGAL_NTS square(qtx) + CGAL_NTS square(qty) + CGAL_NTS square(qtz);
221  FT rtx = rx - tx;
222  FT rty = ry - ty;
223  FT rtz = rz - tz;
224  FT rt2 = CGAL_NTS square(rtx) + CGAL_NTS square(rty) + CGAL_NTS square(rtz);
225  FT stx = sx - tx;
226  FT sty = sy - ty;
227  FT stz = sz - tz;
228  FT st2 = CGAL_NTS square(stx) + CGAL_NTS square(sty) + CGAL_NTS square(stz);
229  return Oriented_side(sign_of_determinant4x4(ptx,pty,ptz,pt2,
230  rtx,rty,rtz,rt2,
231  qtx,qty,qtz,qt2,
232  stx,sty,stz,st2));
233 }
234 
235 template <class FT >
238 side_of_bounded_sphereC3(const FT &px, const FT &py, const FT &pz,
239  const FT &qx, const FT &qy, const FT &qz,
240  const FT &rx, const FT &ry, const FT &rz,
241  const FT &sx, const FT &sy, const FT &sz,
242  const FT &tx, const FT &ty, const FT &tz)
243 {
245  qx, qy, qz,
246  rx, ry, rz,
247  sx, sy, sz,
248  tx, ty, tz);
249  Orientation o = orientationC3(px, py, pz,
250  qx, qy, qz,
251  rx, ry, rz,
252  sx, sy, sz);
253  return Bounded_side(s * o);
254 }
255 
256 template < class FT >
259 cmp_dist_to_pointC3(const FT &px, const FT &py, const FT &pz,
260  const FT &qx, const FT &qy, const FT &qz,
261  const FT &rx, const FT &ry, const FT &rz)
262 {
263  return CGAL_NTS compare(squared_distanceC3(px,py,pz,qx,qy,qz),
264  squared_distanceC3(px,py,pz,rx,ry,rz));
265 }
266 
267 template < class FT >
268 /*CGAL_NO_FILTER*/
270 bool
271 has_larger_dist_to_pointC3(const FT &px, const FT &py, const FT &pz,
272  const FT &qx, const FT &qy, const FT &qz,
273  const FT &rx, const FT &ry, const FT &rz)
274 {
275  return cmp_dist_to_pointC3(px,py,pz,qx,qy,qz,rx,ry,rz) == LARGER;
276 }
277 
278 template < class FT >
279 /*CGAL_NO_FILTER*/
281 bool
282 has_smaller_dist_to_pointC3(const FT &px, const FT &py, const FT &pz,
283  const FT &qx, const FT &qy, const FT &qz,
284  const FT &rx, const FT &ry, const FT &rz)
285 {
286  return cmp_dist_to_pointC3(px,py,pz,qx,qy,qz,rx,ry,rz) == SMALLER;
287 }
288 
289 template < class FT >
293  const FT &pa, const FT &pb, const FT &pc,
294  const FT &px, const FT &py, const FT &pz,
295  const FT &qx, const FT &qy, const FT &qz)
296 {
297  return CGAL_NTS compare(scaled_distance_to_directionC3(pa,pb,pc,px,py,pz),
298  scaled_distance_to_directionC3(pa,pb,pc,qx,qy,qz));
299 }
300 
301 template < class FT >
302 /*CGAL_NO_FILTER*/
304 bool
306  const FT &pa, const FT &pb, const FT &pc,
307  const FT &px, const FT &py, const FT &pz,
308  const FT &qx, const FT &qy, const FT &qz)
309 {
310  return cmp_signed_dist_to_directionC3(pa,pb,pc,px,py,pz,qx,qy,qz) == LARGER;
311 }
312 
313 template < class FT >
314 /*CGAL_NO_FILTER*/
316 bool
318  const FT &pa, const FT &pb, const FT &pc,
319  const FT &px, const FT &py, const FT &pz,
320  const FT &qx, const FT &qy, const FT &qz)
321 {
322  return cmp_signed_dist_to_directionC3(pa,pb,pc,px,py,pz,qx,qy,qz) == SMALLER;
323 }
324 
325 template < class FT >
329  const FT &ppx, const FT &ppy, const FT &ppz,
330  const FT &pqx, const FT &pqy, const FT &pqz,
331  const FT &prx, const FT &pry, const FT &prz,
332  const FT &px, const FT &py, const FT &pz,
333  const FT &qx, const FT &qy, const FT &qz)
334 {
336  pqx-ppx, pqy-ppy, pqz-ppz,
337  prx-ppx, pry-ppy, prz-ppz,
338  qx-px, qy-py, qz-pz));
339 }
340 
341 template < class FT >
342 /*CGAL_NO_FILTER*/
344 bool
346  const FT &ppx, const FT &ppy, const FT &ppz,
347  const FT &pqx, const FT &pqy, const FT &pqz,
348  const FT &prx, const FT &pry, const FT &prz,
349  const FT &px, const FT &py, const FT &pz,
350  const FT &qx, const FT &qy, const FT &qz)
351 {
352  return cmp_signed_dist_to_planeC3(ppx, ppy, ppz, pqx, pqy, pqz,
353  prx, pry, prz, px, py, pz, qx, qy, qz) == LARGER;
354 }
355 
356 template < class FT >
357 /*CGAL_NO_FILTER*/
359 bool
361  const FT &ppx, const FT &ppy, const FT &ppz,
362  const FT &pqx, const FT &pqy, const FT &pqz,
363  const FT &prx, const FT &pry, const FT &prz,
364  const FT &px, const FT &py, const FT &pz,
365  const FT &qx, const FT &qy, const FT &qz)
366 {
367  return cmp_signed_dist_to_planeC3(ppx, ppy, ppz, pqx, pqy, pqz,
368  prx, pry, prz, px, py, pz, qx, qy, qz) == SMALLER;
369 }
370 
372 
373 #ifdef CGAL_ARITHMETIC_FILTER_H
374 #include <CGAL/Arithmetic_filter/predicates/kernel_ftC3.h>
375 #endif
376 
377 #endif // CGAL_PREDICATES_KERNEL_FTC3_H
double square(double x)
CGAL_KERNEL_MEDIUM_INLINE Orientation orientationC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz, const FT &sx, const FT &sy, const FT &sz)
CGAL_KERNEL_MEDIUM_INLINE bool has_smaller_signed_dist_to_planeC3(const FT &ppx, const FT &ppy, const FT &ppz, const FT &pqx, const FT &pqy, const FT &pqz, const FT &prx, const FT &pry, const FT &prz, const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
CGAL_KERNEL_INLINE Comparison_result cmp_dist_to_pointC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz)
static SURF_BEGIN_NAMESPACE double sign(double x)
Sign sign_of_determinant3x3(const FT &a00, const FT &a01, const FT &a02, const FT &a10, const FT &a11, const FT &a12, const FT &a20, const FT &a21, const FT &a22)
CGAL_KERNEL_MEDIUM_INLINE bool dominanceC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
Sign Orientation
Definition: enum.h:64
const NT & d
CGAL_BEGIN_NAMESPACE Sign sign_of_determinant2x2(const FT &a00, const FT &a01, const FT &a10, const FT &a11)
double s
Definition: blastest.C:80
#define CGAL_KERNEL_INLINE
Definition: kernel_basic.h:54
CGAL_KERNEL_MEDIUM_INLINE bool has_larger_signed_dist_to_directionC3(const FT &pa, const FT &pb, const FT &pc, const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
Orientation orientationC2(const FT &px, const FT &py, const FT &qx, const FT &qy, const FT &rx, const FT &ry)
CGAL_KERNEL_MEDIUM_INLINE bool has_larger_signed_dist_to_planeC3(const FT &ppx, const FT &ppy, const FT &ppz, const FT &pqx, const FT &pqy, const FT &pqz, const FT &prx, const FT &pry, const FT &prz, const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
CGAL_KERNEL_MEDIUM_INLINE bool equal_directionC3(const FT &dx1, const FT &dy1, const FT &dz1, const FT &dx2, const FT &dy2, const FT &dz2)
CGAL_KERNEL_MEDIUM_INLINE Comparison_result cmp_signed_dist_to_planeC3(const FT &ppx, const FT &ppy, const FT &ppz, const FT &pqx, const FT &pqy, const FT &pqz, const FT &prx, const FT &pry, const FT &prz, const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
CGAL_KERNEL_MEDIUM_INLINE bool collinear_are_strictly_ordered_along_lineC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz)
Definition: enum.h:96
#define CGAL_KERNEL_MEDIUM_INLINE
Definition: kernel_basic.h:55
Sign
Definition: enum.h:57
Oriented_side
Definition: enum.h:78
CGAL_KERNEL_MEDIUM_INLINE bool has_smaller_signed_dist_to_directionC3(const FT &pa, const FT &pb, const FT &pc, const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
#define CGAL_KERNEL_LARGE_INLINE
Definition: kernel_basic.h:56
CGAL_KERNEL_INLINE FT squared_distanceC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
Sign sign_of_determinant4x4(const FT &a00, const FT &a01, const FT &a02, const FT &a03, const FT &a10, const FT &a11, const FT &a12, const FT &a13, const FT &a20, const FT &a21, const FT &a22, const FT &a23, const FT &a30, const FT &a31, const FT &a32, const FT &a33)
CGAL_KERNEL_MEDIUM_INLINE bool has_larger_dist_to_pointC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz)
CGAL_KERNEL_MEDIUM_INLINE bool collinearC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz)
Comparison_result
Definition: enum.h:94
CGAL_KERNEL_LARGE_INLINE Oriented_side side_of_oriented_sphereC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz, const FT &sx, const FT &sy, const FT &sz, const FT &tx, const FT &ty, const FT &tz)
CGAL_KERNEL_MEDIUM_INLINE bool collinear_are_ordered_along_lineC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz)
CGAL_BEGIN_NAMESPACE CGAL_KERNEL_MEDIUM_INLINE Comparison_result compare_lexicographically_xyzC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
Bounded_side
Definition: enum.h:86
Definition: enum.h:98
CGAL_KERNEL_MEDIUM_INLINE bool strict_dominanceC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
CGAL_KERNEL_MEDIUM_INLINE Bounded_side side_of_bounded_sphereC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz, const FT &sx, const FT &sy, const FT &sz, const FT &tx, const FT &ty, const FT &tz)
CGAL_KERNEL_MEDIUM_INLINE Orientation coplanar_orientationC3(const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz, const FT &sx, const FT &sy, const FT &sz, const FT &px, const FT &py, const FT &pz)
Definition: enum.h:97
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
CGAL_KERNEL_MEDIUM_INLINE Comparison_result cmp_signed_dist_to_directionC3(const FT &pa, const FT &pb, const FT &pc, const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz)
Definition: enum.h:60
CGAL_KERNEL_INLINE Comparison_result compare(const NT &n1, const NT &n2)
Definition: number_utils.h:143
CGAL_KERNEL_LARGE_INLINE Oriented_side side_of_oriented_planeC3(const FT &a, const FT &b, const FT &c, const FT &d, const FT &px, const FT &py, const FT &pz)
#define CGAL_NTS
CGAL_KERNEL_INLINE FT scaled_distance_to_directionC3(const FT &pa, const FT &pb, const FT &pc, const FT &px, const FT &py, const FT &pz)
const Orientation COLLINEAR
Definition: enum.h:72
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
CGAL_KERNEL_MEDIUM_INLINE bool has_smaller_dist_to_pointC3(const FT &px, const FT &py, const FT &pz, const FT &qx, const FT &qy, const FT &qz, const FT &rx, const FT &ry, const FT &rz)