LateralDirectionality.java

  1. package org.opentrafficsim.core.network;

  2. /**
  3.  * Directionality in lateral direction. LEFT is the direction to the left of the longitudinal orientation of the GTU, relative
  4.  * to the forward driving direction. RIGHT is the direction to the right of the longitudinal orientation of the GTU, relative to
  5.  * the forward driving direction.
  6.  * <p>
  7.  * Copyright (c) 2013-2018 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: 2018-09-19 13:55:45 +0200 (Wed, 19 Sep 2018) $, @version $Revision: 4006 $, by $Author: averbraeck $,
  11.  * initial version Oct 15, 2014 <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 LateralDirectionality
  16. {
  17.     /** Direction to the left of the longitudinal orientation of the GTU, relative to the forward driving direction. */
  18.     LEFT,
  19.     /** Direction to the right of the longitudinal orientation of the GTU, relative to the forward driving direction. */
  20.     RIGHT,
  21.     /** Absence of a lateral direction. */
  22.     NONE;

  23.     /**
  24.      * Determine whether the direction is the left direction.
  25.      * @return whether the direction is the left direction
  26.      */
  27.     public boolean isLeft()
  28.     {
  29.         return this.equals(LEFT);
  30.     }

  31.     /**
  32.      * Determine whether the direction is the right direction.
  33.      * @return whether the direction is the right direction
  34.      */
  35.     public boolean isRight()
  36.     {
  37.         return this.equals(RIGHT);
  38.     }

  39.     /**
  40.      * Determine whether the lateral direction is not present.
  41.      * @return whether the lateral direction is not present
  42.      */
  43.     public boolean isNone()
  44.     {
  45.         return this.equals(NONE);
  46.     }

  47.     /**
  48.      * Returns the other direction.
  49.      * @return other direction
  50.      */
  51.     public LateralDirectionality flip()
  52.     {
  53.         return this.equals(NONE) ? NONE : this.equals(LEFT) ? RIGHT : LEFT;
  54.     }

  55. }