All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentrafficsim.draw.egtf.GaussKernelShape Maven / Gradle / Ivy

The newest version!
package org.opentrafficsim.draw.egtf;

/**
 * Gaussian implementation of a shape.
 * 

* Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License. *

* @author Alexander Verbraeck * @author Peter Knoppers * @author Wouter Schakel */ public class GaussKernelShape implements KernelShape { /** Twice the spatial size of the kernel to the power of 2. */ private final double sigma2; /** Twice the temporal size of the kernel to the power of 2. */ private final double tau2; /** * Constructor. * @param sigma double; spatial size of the kernel * @param tau double; temporal size of the kernel */ GaussKernelShape(final double sigma, final double tau) { this.sigma2 = 2.0 * sigma * sigma; this.tau2 = 2.0 * tau * tau; } /** {@inheritDoc} */ @Override public double weight(final double c, final double dx, final double dt) { double dtt = dt - dx / c; return Math.exp(-(dx * dx) / this.sigma2 - dtt * dtt / this.tau2); } /** {@inheritDoc} */ @Override public String toString() { return "GaussKernelShape [sigma=" + Math.sqrt(this.sigma2 / 2.0) + ", tau=" + Math.sqrt(this.tau2 / 2.0) + "]"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy