SUMO - Simulation of Urban MObility
Position.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // A position in the 2D- or 3D-world
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <limits>
27 #include "Position.h"
28 
29 
30 // ===========================================================================
31 // static member definitions
32 // ===========================================================================
33 
34 // Position 1Mio km below the surface should suffice for signaling invalidity inside the solar system
36  - 1024 * 1024 * 1024,
37  - 1024 * 1024 * 1024,
38  - 1024 * 1024 * 1024);
39 
40 
42 Position::rotateAround2D(double rad, const Position& origin) {
43  const double s = sin(rad);
44  const double c = cos(rad);
45  Position p = (*this) - origin;
46  return Position(
47  p.x() * c - p.y() * s,
48  p.x() * s + p.y() * c) + origin;
49 
50 }
double y() const
Returns the y-position.
Definition: Position.h:62
double x() const
Returns the x-position.
Definition: Position.h:57
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
Position rotateAround2D(double rad, const Position &origin)
rotate this position by rad around origin and return the result
Definition: Position.cpp:42
Position()
default constructor
Definition: Position.h:42
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:285