Kernel.java

  1. package org.opentrafficsim.draw.egtf;

  2. /**
  3.  * Kernel with maximum range and shape.
  4.  * <p>
  5.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  6.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  7.  * </p>
  8.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  9.  */
  10. public class Kernel
  11. {

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

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

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

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

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

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

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

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

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

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

  82. }