1 package org.opentrafficsim.draw.egtf; 2 3 /** 4 * Gaussian implementation of a shape. 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/averbraeck">Alexander Verbraeck</a> 10 * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a> 11 * @author <a href="https://github.com/wjschakel">Wouter Schakel</a> 12 */ 13 public class GaussKernelShape implements KernelShape 14 { 15 16 /** Twice the spatial size of the kernel to the power of 2. */ 17 private final double sigma2; 18 19 /** Twice the temporal size of the kernel to the power of 2. */ 20 private final double tau2; 21 22 /** 23 * Constructor. 24 * @param sigma double; spatial size of the kernel 25 * @param tau double; temporal size of the kernel 26 */ 27 GaussKernelShape(final double sigma, final double tau) 28 { 29 this.sigma2 = 2.0 * sigma * sigma; 30 this.tau2 = 2.0 * tau * tau; 31 } 32 33 /** {@inheritDoc} */ 34 @Override 35 public double weight(final double c, final double dx, final double dt) 36 { 37 double dtt = dt - dx / c; 38 return Math.exp(-(dx * dx) / this.sigma2 - dtt * dtt / this.tau2); 39 } 40 41 /** {@inheritDoc} */ 42 @Override 43 public String toString() 44 { 45 return "GaussKernelShape [sigma=" + Math.sqrt(this.sigma2 / 2.0) + ", tau=" + Math.sqrt(this.tau2 / 2.0) + "]"; 46 } 47 48 }