Kernel.java

  1. package org.opentrafficsim.core.egtf;

  2. /**
  3.  * Kernel with maximum range and shape.
  4.  * <p>
  5.  * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  6.  * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
  7.  * <p>
  8.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version 24 okt. 2018 <br>
  9.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  10.  */
  11. public class Kernel
  12. {

  13.     /** Maximum spatial range. */
  14.     private final double xMax;

  15.     /** Maximum temporal range. */
  16.     private final double tMax;

  17.     /** Shape of the kernel. */
  18.     private final KernelShape shape;

  19.     /**
  20.      * Constructor.
  21.      * @param xMax double; maximum spatial range
  22.      * @param tMax double; maximum temporal range
  23.      * @param shape KernelShape; shape of the kernel
  24.      */
  25.     Kernel(final double xMax, final double tMax, final KernelShape shape)
  26.     {
  27.         this.xMax = xMax;
  28.         this.tMax = tMax;
  29.         this.shape = shape;
  30.     }

  31.     /**
  32.      * Returns a weight assuming given propagation speed.
  33.      * @param c double; assumed propagation speed
  34.      * @param dx double; distance between measurement and estimated point
  35.      * @param dt double; time between measurement and estimated point
  36.      * @return double; weight assuming given propagation speed
  37.      */
  38.     final double weight(final double c, final double dx, final double dt)
  39.     {
  40.         return this.shape.weight(c, dx, dt);
  41.     }

  42.     /**
  43.      * Returns the from location of the valid data range.
  44.      * @param x double; location of estimated point
  45.      * @return double; from location of the valid data range
  46.      */
  47.     final double fromLocation(final double x)
  48.     {
  49.         return x - this.xMax;
  50.     }

  51.     /**
  52.      * Returns the to location of the valid data range.
  53.      * @param x double; location of estimated point
  54.      * @return double; to location of the valid data range
  55.      */
  56.     final double toLocation(final double x)
  57.     {
  58.         return x + this.xMax;
  59.     }

  60.     /**
  61.      * Returns the from time of the valid data range.
  62.      * @param t double; time of estimated point
  63.      * @return double; from time of the valid data range
  64.      */
  65.     final double fromTime(final double t)
  66.     {
  67.         return t - this.tMax;
  68.     }

  69.     /**
  70.      * Returns the to time of the valid data range.
  71.      * @param t double; time of estimated point
  72.      * @return double; to time of the valid data range
  73.      */
  74.     final double toTime(final double t)
  75.     {
  76.         return t + this.tMax;
  77.     }

  78.     /** {@inheritDoc} */
  79.     @Override
  80.     public String toString()
  81.     {
  82.         return "Kernel [tMax=" + this.tMax + ", xMax=" + this.xMax + ", shape=" + this.shape + "]";
  83.     }

  84. }