Package trclib.dataprocessor
Class TrcWarpSpace
java.lang.Object
trclib.dataprocessor.TrcWarpSpace
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 -
Constructor Summary
ConstructorsConstructorDescriptionTrcWarpSpace
(String instanceName, double warpSpaceLowPoint, double warpSpaceHighPoint) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
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.toString()
This method returns the instance name.
-
Field Details
-
instanceName
-
warpSpaceRange
private final double warpSpaceRange
-
-
Constructor Details
-
TrcWarpSpace
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
This method returns the 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.
-