Class TrcWarpSpace

java.lang.Object
trclib.dataprocessor.TrcWarpSpace

public class TrcWarpSpace extends Object
This class implements a generic warp space. A warp space is originally a linear space with two points: a low point A and a high point B. The space is warped such that point A and point B represent the same physical position in space even though the linear distance between the two points is far away. A typical example of warp space is demonstrated by a compass. A compass has a low point of 0-degree and a high point of 360-degree but these two points are at the same physical position (NORTH).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
     
    private final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TrcWarpSpace(String instanceName, double warpSpaceLowPoint, double warpSpaceHighPoint)
    Constructor: Creates an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    getOptimizedTarget(double targetPos, double currentPos)
    This method returns the optimized target position such that the travel distance to the target is minimum.
    static double
    getOptimizedTarget(double targetPos, double currentPos, double range)
    This method returns the optimized target position such that the travel distance to the target is minimum.
    This method returns the instance name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • instanceName

      private final String instanceName
    • warpSpaceRange

      private final double warpSpaceRange
  • Constructor Details

    • TrcWarpSpace

      public TrcWarpSpace(String instanceName, double warpSpaceLowPoint, double warpSpaceHighPoint)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      warpSpaceLowPoint - specifies the low point of the warp range.
      warpSpaceHighPoint - specifies the high point of the warp range.
  • Method Details

    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • getOptimizedTarget

      public static double getOptimizedTarget(double targetPos, double currentPos, double range)
      This method returns the optimized target position such that the travel distance to the target is minimum. In the compass example, if one is currently headed NORTH (0-degree) and wants to turn to WEST (270-degree), one may turn all the way 270 degrees clockwise and landed pointing WEST. But one could also turn towards the warp point (0-degree), passed it and landed WEST by turning counter clockwise 90 degrees.
      Parameters:
      targetPos - specifies the target position.
      currentPos - specifies the current position.
      range - specifies the warp space range.
      Returns:
      optimized target position resulted in shorter traveling distance.
    • getOptimizedTarget

      public double getOptimizedTarget(double targetPos, double currentPos)
      This method returns the optimized target position such that the travel distance to the target is minimum. In the compass example, if one is currently headed NORTH (0-degree) and wants to turn to WEST (270-degree), one may turn all the way 270 degrees clockwise and landed pointing WEST. But one could also turn towards the warp point (0-degree), passed it and landed WEST by turning counter clockwise 90 degrees.
      Parameters:
      targetPos - specifies the target position.
      currentPos - specifies the current position.
      Returns:
      optimized target position resulted in shorter traveling distance.