BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/predicates/Regular_triangulation_ftC3.h
Go to the documentation of this file.
00001 // Copyright (c) 1999  INRIA Sophia-Antipolis (France).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under
00005 // the terms of the Q Public License version 1.0.
00006 // See the file LICENSE.QPL distributed with CGAL.
00007 //
00008 // Licensees holding a valid commercial license may use this file in
00009 // accordance with the commercial license agreement provided with the software.
00010 //
00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 //
00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Triangulation_3/include/CGAL/predicates/Regular_triangulation_ftC3.h $
00015 // $Id: Regular_triangulation_ftC3.h 46206 2008-10-11 20:21:08Z spion $
00016 // 
00017 //
00018 // Author(s)     : Sylvain Pion
00019 
00020 #ifndef CGAL_REGULAR_TRIANGULATION_FTC3_H
00021 #define CGAL_REGULAR_TRIANGULATION_FTC3_H
00022 
00023 // This file contains the low level cartesian predicates
00024 // used by the 3D regular triangulation.
00025 
00026 CGAL_BEGIN_NAMESPACE
00027 
00028 // return minus the sign of the 5x5 determinant [P,Q,R,S,T]
00029 // where column [P] = transpose[px,py,pz,p^2 -wp,1]
00030 template <class FT>
00031 Oriented_side
00032 power_testC3( const FT &px, const FT &py, const FT &pz, const FT &pwt,
00033               const FT &qx, const FT &qy, const FT &qz, const FT &qwt,
00034               const FT &rx, const FT &ry, const FT &rz, const FT &rwt,
00035               const FT &sx, const FT &sy, const FT &sz, const FT &swt,
00036               const FT &tx, const FT &ty, const FT &tz, const FT &twt)
00037 {
00038     // We translate the points so that T becomes the origin.
00039     FT dpx = px - tx;
00040     FT dpy = py - ty;
00041     FT dpz = pz - tz;
00042     FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + 
00043              CGAL_NTS square(dpz) - pwt + twt;
00044     FT dqx = qx - tx;
00045     FT dqy = qy - ty;
00046     FT dqz = qz - tz;
00047     FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) +
00048              CGAL_NTS square(dqz) - qwt + twt;
00049     FT drx = rx - tx;
00050     FT dry = ry - ty;
00051     FT drz = rz - tz;
00052     FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) + 
00053              CGAL_NTS square(drz) - rwt + twt;
00054     FT dsx = sx - tx;
00055     FT dsy = sy - ty;
00056     FT dsz = sz - tz;
00057     FT dst = CGAL_NTS square(dsx) + CGAL_NTS square(dsy) + 
00058              CGAL_NTS square(dsz) - swt + twt;
00059 
00060     return - sign_of_determinant(dpx, dpy, dpz, dpt,
00061                                  dqx, dqy, dqz, dqt,
00062                                  drx, dry, drz, drt,
00063                                  dsx, dsy, dsz, dst);
00064 }
00065 
00066 
00067 template <class FT>
00068 Oriented_side
00069 power_testC3( const FT &px, const FT &py, const FT &pz, const FT &pwt,
00070               const FT &qx, const FT &qy, const FT &qz, const FT &qwt,
00071               const FT &rx, const FT &ry, const FT &rz, const FT &rwt,
00072               const FT &tx, const FT &ty, const FT &tz, const FT &twt)
00073 {
00074     // Same translation as above.
00075     FT dpx = px - tx;
00076     FT dpy = py - ty;
00077     FT dpz = pz - tz;
00078     FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + 
00079              CGAL_NTS square(dpz) - pwt + twt;
00080     FT dqx = qx - tx;
00081     FT dqy = qy - ty;
00082     FT dqz = qz - tz;
00083     FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) + 
00084              CGAL_NTS square(dqz) - qwt + twt;
00085     FT drx = rx - tx;
00086     FT dry = ry - ty;
00087     FT drz = rz - tz;
00088     FT drt = CGAL_NTS square(drx) + CGAL_NTS square(dry) + 
00089              CGAL_NTS square(drz) - rwt + twt;
00090     Sign cmp;
00091 
00092     // Projection on the (xy) plane.
00093     cmp = sign_of_determinant(dpx, dpy, dpt,
00094                                  dqx, dqy, dqt,
00095                                  drx, dry, drt);
00096     if (cmp != ZERO)
00097         return cmp * sign_of_determinant(px-rx, py-ry,
00098                                          qx-rx, qy-ry);
00099 
00100     // Projection on the (xz) plane.
00101     cmp = sign_of_determinant(dpx, dpz, dpt,
00102                                  dqx, dqz, dqt,
00103                                  drx, drz, drt);
00104     if (cmp != ZERO)
00105         return cmp * sign_of_determinant(px-rx, pz-rz,
00106                                          qx-rx, qz-rz);
00107 
00108     // Projection on the (yz) plane.
00109     cmp = sign_of_determinant(dpy, dpz, dpt,
00110                                  dqy, dqz, dqt,
00111                                  dry, drz, drt);
00112     return cmp * sign_of_determinant(py-ry, pz-rz,
00113                                      qy-ry, qz-rz);
00114 }
00115 
00116 
00117 template <class FT>
00118 Oriented_side
00119 power_testC3( const FT &px, const FT &py, const FT &pz, const FT &pwt,
00120               const FT &qx, const FT &qy, const FT &qz, const FT &qwt,
00121               const FT &tx, const FT &ty, const FT &tz, const FT &twt)
00122 {
00123     // Same translation as above.
00124     FT dpx = px - tx;
00125     FT dpy = py - ty;
00126     FT dpz = pz - tz;
00127     FT dpt = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + 
00128              CGAL_NTS square(dpz) - pwt + twt;
00129     FT dqx = qx - tx;
00130     FT dqy = qy - ty;
00131     FT dqz = qz - tz;
00132     FT dqt = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) + 
00133              CGAL_NTS square (dqz) - qwt + twt;
00134     Comparison_result cmp;
00135 
00136     // We do an orthogonal projection on the (x) axis, if possible.
00137     cmp = CGAL_NTS compare(px, qx);
00138     if (cmp != EQUAL)
00139         return cmp * sign_of_determinant(dpx, dpt, dqx, dqt);
00140 
00141     // We do an orthogonal projection on the (y) axis, if possible.
00142     cmp = CGAL_NTS compare(py, qy);
00143     if (cmp != EQUAL)
00144         return cmp * sign_of_determinant(dpy, dpt, dqy, dqt);
00145 
00146     // We do an orthogonal projection on the (z) axis.
00147     cmp = CGAL_NTS compare(pz, qz);
00148     return cmp * sign_of_determinant(dpz, dpt, dqz, dqt);
00149 }
00150 
00151 template <class FT>
00152 Oriented_side
00153 power_testC3(const FT &pwt, const FT &qwt)
00154 {
00155     return CGAL_NTS compare(qwt, pwt);
00156 }
00157 
00158 CGAL_END_NAMESPACE
00159 
00160 #endif // CGAL_REGULAR_TRIANGULATION_FTC3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines