vtf-logo

simplex_distance.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_simplex_distance_h__)
00009 #define __geom_simplex_distance_h__
00010 
00011 #if defined(DEBUG_geom) && !defined(DEBUG_simplex_distance)
00012 #define DEBUG_simplex_distance
00013 #endif
00014 
00015 #include "Simplex.h"
00016 
00017 #include "../../kernel/Line_2.h"
00018 #include "../../kernel/Plane.h"
00019 
00020 BEGIN_NAMESPACE_GEOM
00021 
00022 //---------------------------------------------------------------------------
00023 // Inside tests.
00024 //---------------------------------------------------------------------------
00025 
00027 
00035 template<typename T>
00036 bool
00037 isIn(const Simplex<1,ads::FixedArray<1,T>,T>& s, 
00038      const ads::FixedArray<1,T>& x);
00039 
00041 
00054 template<typename T>
00055 bool
00056 isIn(const Simplex<2,ads::FixedArray<2,T>,T>& s, 
00057      const ads::FixedArray<2,T>& x);
00058 
00060 
00073 template<typename T>
00074 bool
00075 isIn(const Simplex<3,ads::FixedArray<3,T>,T>& s, 
00076      const ads::FixedArray<3,T>& x);
00077 
00078 
00079 //---------------------------------------------------------------------------
00080 // Interior distance.
00081 //---------------------------------------------------------------------------
00082 
00083 
00085 
00096 template<typename T>
00097 T
00098 computeDistanceInterior(const Simplex<1,ads::FixedArray<1,T>,T>& s, 
00099                         const ads::FixedArray<1,T>& x);
00100 
00101 
00103 
00115 template<typename T>
00116 T
00117 computeDistanceInterior(const Simplex<2,ads::FixedArray<2,T>,T>& s, 
00118                         const ads::FixedArray<2,T>& x);
00119 
00120 
00122 
00134 template<typename T>
00135 T
00136 computeDistanceInterior(const Simplex<3,ads::FixedArray<3,T>,T>& s, 
00137                         const ads::FixedArray<3,T>& x);
00138 
00139 
00140 //---------------------------------------------------------------------------
00141 // Distance.
00142 //---------------------------------------------------------------------------
00143 
00145 
00153 template<typename T>
00154 T
00155 computeDistance(const Simplex<1,ads::FixedArray<1,T>,T>& s, 
00156                 const ads::FixedArray<1,T>& x);
00157 
00159 
00167 template<typename T>
00168 T
00169 computeDistance(const Simplex<1,ads::FixedArray<2,T>,T>& s, 
00170                 const ads::FixedArray<2,T>& x);
00171 
00173 
00181 template<typename T>
00182 T
00183 computeDistance(const Simplex<1,ads::FixedArray<3,T>,T>& s, 
00184                 const ads::FixedArray<3,T>& x);
00185 
00187 
00196 template<typename T>
00197 T
00198 computeDistance(const Simplex<2,ads::FixedArray<2,T>,T>& s, 
00199                 const ads::FixedArray<2,T>& x);
00200 
00202 
00211 template<typename T>
00212 T
00213 computeDistance(const Simplex<2,ads::FixedArray<3,T>,T>& s, 
00214                 const ads::FixedArray<3,T>& x);
00215 
00217 
00226 template<typename T>
00227 T
00228 computeDistance(const Simplex<3,ads::FixedArray<3,T>,T>& s, 
00229                 const ads::FixedArray<3,T>& x);
00230 
00231 
00232 //---------------------------------------------------------------------------
00233 // Unsigned distance.
00234 //---------------------------------------------------------------------------
00235 
00236 
00238 
00247 template<typename T>
00248 inline
00249 T
00250 computeUnsignedDistance(const Simplex<1,ads::FixedArray<1,T>,T>& s, 
00251                         const ads::FixedArray<1,T>& x) {
00252   return std::max(0., computeDistance(s, x));
00253 }
00254 
00255 
00257 
00266 template<typename T>
00267 inline
00268 T
00269 computeUnsignedDistance(const Simplex<2,ads::FixedArray<2,T>,T>& s, 
00270                         const ads::FixedArray<2,T>& x) {
00271   return std::max(0., computeDistance(s, x));
00272 }
00273 
00274 
00276 
00285 template<typename T>
00286 inline
00287 T
00288 computeUnsignedDistance(const Simplex<3,ads::FixedArray<3,T>,T>& s, 
00289                         const ads::FixedArray<3,T>& x) {
00290   return std::max(0., computeDistance(s, x));
00291 }
00292 
00293 
00294 //---------------------------------------------------------------------------
00295 // Signed distance.
00296 //---------------------------------------------------------------------------
00297 
00298 
00300 
00310 template<int N, typename T>
00311 T
00312 computeSignedDistance(const ads::FixedArray<N,T>& p,
00313                       const ads::FixedArray<N,T>& n,
00314                       const ads::FixedArray<N,T>& x);
00315 
00316 
00318 
00329 template<typename T>
00330 T
00331 computeSignedDistance(const Simplex<1,ads::FixedArray<2,T>,T>& s, 
00332                       const ads::FixedArray<2,T>& x);
00333 
00334 
00336 
00348 template<typename T>
00349 T
00350 computeSignedDistance(const Simplex<1,ads::FixedArray<2,T>,T>& s, 
00351                       const ads::FixedArray<2,T>& x,
00352                       ads::FixedArray<2,T>* closestPoint);
00353 
00354 
00356 
00367 template<typename T>
00368 T
00369 computeSignedDistance(const Simplex<2,ads::FixedArray<3,T>,T>& s, 
00370                       const ads::FixedArray<3,T>& x);
00371 
00372 
00374 
00387 template<typename T>
00388 T
00389 computeSignedDistance(const Simplex<2,ads::FixedArray<3,T>,T>& s, 
00390                       const ads::FixedArray<3,T>& n,
00391                       const ads::FixedArray<3,T>& x,
00392                       ads::FixedArray<3,T>* closestPoint);
00393 
00394 
00396 
00409 template<typename T>
00410 T
00411 computeSignedDistance(const Simplex<1,ads::FixedArray<3,T>,T>& s, 
00412                       const ads::FixedArray<3,T>& n,
00413                       const ads::FixedArray<3,T>& x);
00414 
00415 
00417 
00431 template<typename T>
00432 T
00433 computeSignedDistance(const Simplex<1,ads::FixedArray<3,T>,T>& s, 
00434                       const ads::FixedArray<3,T>& n,
00435                       const ads::FixedArray<3,T>& x,
00436                       ads::FixedArray<3,T>* closestPoint);
00437 
00438 
00439 //---------------------------------------------------------------------------
00440 // Project to a lower dimension.
00441 //---------------------------------------------------------------------------
00442 
00443 
00445 
00455 template<typename T>
00456 void
00457 project(const Simplex<1,ads::FixedArray<2,T>,T>& s2, 
00458         const ads::FixedArray<2,T>& x2,
00459         Simplex<1,ads::FixedArray<1,T>,T>* s1, 
00460         ads::FixedArray<1,T>* x1);
00461 
00463 
00474 template<typename T>
00475 void
00476 project(const Simplex<1,ads::FixedArray<2,T>,T>& s2, 
00477         const ads::FixedArray<2,T>& x2,
00478         Simplex<1,ads::FixedArray<1,T>,T>* s1, 
00479         ads::FixedArray<1,T>* x1,
00480         ads::FixedArray<1,T>* y1);
00481 
00483 
00494 template<typename T>
00495 void
00496 project(const Simplex<2,ads::FixedArray<3,T>,T>& s3, 
00497         const ads::FixedArray<3,T>& x3,
00498         Simplex<2,ads::FixedArray<2,T>,T>* s2, 
00499         ads::FixedArray<2,T>* x2);
00500 
00502 
00514 template<typename T>
00515 void
00516 project(const Simplex<2,ads::FixedArray<3,T>,T>& s3, 
00517         const ads::FixedArray<3,T>& x3,
00518         Simplex<2,ads::FixedArray<2,T>,T>* s2, 
00519         ads::FixedArray<2,T>* x2,
00520         ads::FixedArray<1,T>* z1);
00521 
00522 
00523 //---------------------------------------------------------------------------
00524 // Closest Point.
00525 //---------------------------------------------------------------------------
00526 
00528 
00537 template<typename T>
00538 T
00539 computeClosestPoint(const Simplex<1,ads::FixedArray<2,T>,T>& simplex, 
00540                     const ads::FixedArray<2,T>& point,
00541                     ads::FixedArray<2,T>* closestPoint);
00542 
00543 
00544 END_NAMESPACE_GEOM
00545 
00546 #define __geom_simplex_distance_ipp__
00547 #include "simplex_distance.ipp"
00548 #undef __geom_simplex_distance_ipp__
00549 
00550 #endif

Generated on Fri Aug 24 12:55:57 2007 for Computational Geometry Package by  doxygen 1.4.7