SUMO - Simulation of Urban MObility
Helper_ConvexHull.h
Go to the documentation of this file.
1 /****************************************************************************/
8 //
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef Helper_ConvexHull_h
22 #define Helper_ConvexHull_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 
29 
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include "Position.h"
37 #include "PositionVector.h"
38 #include <vector>
39 
40 // Copyright 2002, softSurfer (www.softsurfer.com)
41 // This code may be freely used and modified for any purpose
42 // providing that this copyright notice is included with it.
43 // SoftSurfer makes no warranty for this code, and cannot be held
44 // liable for any real or imagined damage resulting from its use.
45 // Users of this code must verify correctness for their application.
46 
47 
48 // Assume that a class is already given for the object:
49 // Position with coordinates {SUMOReal x, y;}
50 //===================================================================
51 
52 
53 // isLeft(): test if a Position is Left|On|Right of an infinite line.
54 // Input: three Positions P0, P1, and P2
55 // Return: >0 for P2 left of the line through P0 and P1
56 // =0 for P2 on the line
57 // <0 for P2 right of the line
58 // See: the January 2001 Algorithm on Area of Triangles
59 
60 
61 inline SUMOReal
62 isLeft(const Position& P0,
63  const Position& P1,
64  const Position& P2) {
65  return (P1.x() - P0.x()) * (P2.y() - P0.y()) - (P2.x() - P0.x()) * (P1.y() - P0.y());
66 }
67 
68 
71 
72 
73 #endif
74 
75 /****************************************************************************/
76 
SUMOReal isLeft(const Position &P0, const Position &P1, const Position &P2)
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
#define SUMOReal
Definition: config.h:218
PositionVector simpleHull_2D(const PositionVector &V)