1 package org.opentrafficsim.core.gtu;
2
3 /**
4 * Longitudinal driving directions for a GTU. The driving directions can be used on a link or a lane. The two possible values
5 * are <code>DIR_PLUS</code> and <code>DIR_MINUS</code>.
6 * <p>
7 * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
8 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
9 * <p>
10 * $LastChangedDate: 2015-11-11 13:25:26 +0100 (Wed, 11 Nov 2015) $, @version $Revision: 1548 $, by $Author: averbraeck $,
11 * initial version Nov 11, 2015 <br>
12 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
13 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
14 */
15 public enum GTUDirectionality
16 {
17 /**
18 * Driving direction matches the direction of the graph, increasing fractional position when driving in this direction.
19 */
20 DIR_PLUS,
21 /**
22 * Driving direction opposite to the direction of the graph, decreasing fractional position when driving in this direction.
23 */
24 DIR_MINUS;
25
26 /**
27 * @return whether the gtu drives in the design direction on the link
28 */
29 public boolean isPlus()
30 {
31 return this.equals(DIR_PLUS);
32 }
33
34 /**
35 * @return whether the gtu drives against the design direction on the link
36 */
37 public boolean isMinus()
38 {
39 return this.equals(DIR_MINUS);
40 }
41
42 /**
43 * Returns the flipped direction.
44 * @return GTUDirectionality; flipped direction.
45 */
46 public GTUDirectionality flip()
47 {
48 return isPlus() ? DIR_MINUS : DIR_PLUS;
49 }
50 }