1 package org.opentrafficsim.draw.egtf;
2
3 /**
4 * Exponential implementation of a shape. Used as default when kernels are created.
5 * <p>
6 * Copyright (c) 2013-2024 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://github.com/wjschakel">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 spatial size of the kernel
23 * @param tau 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 @Override
32 public double weight(final double c, final double dx, final double dt)
33 {
34 return Math.exp(-Math.abs(dx) / this.sigma - Math.abs(dt - dx / c) / this.tau);
35 }
36
37 @Override
38 public String toString()
39 {
40 return "ExpKernelShape [sigma=" + this.sigma + ", tau=" + this.tau + "]";
41 }
42
43 }