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-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
7 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
8 * </p>
9 * @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>
10 */
11 public class ExpKernelShape implements KernelShape
12 {
13
14 /** Spatial size of the kernel. */
15 private final double sigma;
16
17 /** Temporal size of the kernel. */
18 private final double tau;
19
20 /**
21 * Constructor.
22 * @param sigma double; spatial size of the kernel
23 * @param tau double; temporal size of the kernel
24 */
25 ExpKernelShape(final double sigma, final double tau)
26 {
27 this.sigma = sigma;
28 this.tau = tau;
29 }
30
31 /** {@inheritDoc} */
32 @Override
33 public double weight(final double c, final double dx, final double dt)
34 {
35 return Math.exp(-Math.abs(dx) / this.sigma - Math.abs(dt - dx / c) / this.tau);
36 }
37
38 /** {@inheritDoc} */
39 @Override
40 public String toString()
41 {
42 return "ExpKernelShape [sigma=" + this.sigma + ", tau=" + this.tau + "]";
43 }
44
45 }