View Javadoc
1   package org.opentrafficsim.core.egtf;
2   
3   /**
4    * Exponential implementation of a shape. Used as default when kernels are created.
5    * <p>
6    * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
7    * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
8    * <p>
9    * @version $Revision$, $LastChangedDate$, by $Author$, initial version 24 okt. 2018 <br>
10   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
11   */
12  public class ExpKernelShape implements KernelShape
13  {
14  
15      /** Spatial size of the kernel. */
16      private final double sigma;
17  
18      /** Temporal size of the kernel. */
19      private final double tau;
20  
21      /**
22       * Constructor.
23       * @param sigma double; spatial size of the kernel
24       * @param tau double; temporal size of the kernel
25       */
26      ExpKernelShape(final double sigma, final double tau)
27      {
28          this.sigma = sigma;
29          this.tau = tau;
30      }
31  
32      /** {@inheritDoc} */
33      @Override
34      public double weight(final double c, final double dx, final double dt)
35      {
36          return Math.exp(-Math.abs(dx) / this.sigma - Math.abs(dt - dx / c) / this.tau);
37      }
38  
39      /** {@inheritDoc} */
40      @Override
41      public String toString()
42      {
43          return "ExpKernelShape [sigma=" + this.sigma + ", tau=" + this.tau + "]";
44      }
45  
46  }