00001 /****************************************************************************/ 00007 // 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef Helper_ConvexHull_h 00020 #define Helper_ConvexHull_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 00027 00028 #ifdef _MSC_VER 00029 #include <windows_config.h> 00030 #else 00031 #include <config.h> 00032 #endif 00033 00034 #include "Position2D.h" 00035 #include "Position2DVector.h" 00036 #include <vector> 00037 00038 // Copyright 2002, softSurfer (www.softsurfer.com) 00039 // This code may be freely used and modified for any purpose 00040 // providing that this copyright notice is included with it. 00041 // SoftSurfer makes no warranty for this code, and cannot be held 00042 // liable for any real or imagined damage resulting from its use. 00043 // Users of this code must verify correctness for their application. 00044 00045 00046 // Assume that a class is already given for the object: 00047 // Position2D with coordinates {SUMOReal x, y;} 00048 //=================================================================== 00049 00050 00051 // isLeft(): test if a Position2D is Left|On|Right of an infinite line. 00052 // Input: three Position2Ds P0, P1, and P2 00053 // Return: >0 for P2 left of the line through P0 and P1 00054 // =0 for P2 on the line 00055 // <0 for P2 right of the line 00056 // See: the January 2001 Algorithm on Area of Triangles 00057 00058 00059 inline SUMOReal 00060 isLeft(const Position2D &P0, 00061 const Position2D &P1, 00062 const Position2D &P2) { 00063 return (P1.x() - P0.x())*(P2.y() - P0.y()) - (P2.x() - P0.x())*(P1.y() - P0.y()); 00064 } 00065 00066 00067 Position2DVector 00068 simpleHull_2D(const Position2DVector &V); 00069 00070 00071 #endif 00072 00073 /****************************************************************************/ 00074
1.5.6