GeomHelper.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Some geometrical helpers
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 GeomHelper_h
00020 #define GeomHelper_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include "Position2D.h"
00033 #include "Position2DVector.h"
00034 #include <utils/common/UtilExceptions.h>
00035 
00036 
00037 #ifndef PI
00038 #define PI 3.1415926535897932384626433832795
00039 #endif
00040 
00041 // ===========================================================================
00042 // class definitions
00043 // ===========================================================================
00047 class GeomHelper {
00048 public:
00049     static bool intersects(SUMOReal x1b, SUMOReal y1b, SUMOReal x1e, SUMOReal y1e,
00050                            SUMOReal x2b, SUMOReal y2b, SUMOReal x2e, SUMOReal y2e);
00051 
00052     static bool intersects(const Position2D &p11, const Position2D &p12,
00053                            const Position2D &p21, const Position2D &p22);
00054 
00055     static Position2D intersection_position(const Position2D &p11,
00056                                             const Position2D &p12, const Position2D &p21, const Position2D &p22);
00057 
00058     static SUMOReal Angle2D(SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2);
00059 
00060     static Position2D interpolate(const Position2D &p1,
00061                                   const Position2D &p2, SUMOReal length);
00062 
00063     static Position2D extrapolate_first(const Position2D &p1,
00064                                         const Position2D &p2, SUMOReal length);
00065 
00066     static Position2D extrapolate_second(const Position2D &p1,
00067                                          const Position2D &p2, SUMOReal length);
00068 
00069     static SUMOReal nearest_position_on_line_to_point(
00070         const Position2D &l1, const Position2D &l2,
00071         const Position2D &p);
00072 
00074     static SUMOReal distancePointLine(const Position2D &point,
00075                                       const Position2D &lineStart, const Position2D &lineEnd);
00076 
00081     static SUMOReal closestDistancePointLine(const Position2D &point,
00082             const Position2D &lineStart, const Position2D &lineEnd,
00083             Position2D& outIntersection);
00084 
00085     static Position2D transfer_to_side(Position2D &p,
00086                                        const Position2D &lineBeg, const Position2D &lineEnd,
00087                                        SUMOReal amount);
00088 
00089 
00090     static Position2D crossPoint(const Boundary &b,
00091                                  const Position2DVector &v);
00092 
00093     static std::pair<SUMOReal, SUMOReal> getNormal90D_CW(const Position2D &beg,
00094             const Position2D &end, SUMOReal length, SUMOReal wanted_offset);
00095 
00096     static std::pair<SUMOReal, SUMOReal> getNormal90D_CW(const Position2D &beg,
00097             const Position2D &end, SUMOReal wanted_offset);
00098 
00104     static SUMOReal getCCWAngleDiff(SUMOReal angle1, SUMOReal angle2) throw();
00105 
00106 
00112     static SUMOReal getCWAngleDiff(SUMOReal angle1, SUMOReal angle2) throw();
00113 
00114 
00120     static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2) throw();
00121 
00122 
00128     static SUMOReal getMaxAngleDiff(SUMOReal angle1, SUMOReal angle2) throw();
00129 
00130 
00131 };
00132 
00133 
00134 #endif
00135 
00136 /****************************************************************************/
00137 

Generated on Wed May 5 00:06:29 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6