Class SegmentInterpolator
public class SegmentInterpolator
extends java.lang.Object
- Since:
- 0.4.0
- Author:
- Colin Robertson
-
Field Summary
Fields Modifier and Type Field Description private double
minX
The minimum X value contained in the segment.private double
minY
The minimum Y value contained in the segment.private Segment
segment
The segment which will be interpolated.private double
sizeX
The size of the range between the minimum and maximum X values.private double
sizeY
The size of the range between the minimum and maximum Y values.private me.wobblyyyy.intra.ftc2.utils.math.Range
xRange
A range of X values.private me.wobblyyyy.intra.ftc2.utils.math.Range
yRange
A range of Y values. -
Constructor Summary
Constructors Constructor Description SegmentInterpolator(Segment segment)
Create a newSegmentInterpolator
that will interpolate the provided segment to the best of its ability. -
Method Summary
Modifier and Type Method Description Point
atPercent(double percent)
Deprecated, for removal: This API element is subject to removal in a future version.This method's return values can be inaccurate for certain types of segments, specifically monotone cubic splines.Point
atPercentX(double percentX)
Get an X-Y point based a percentage of completion of the total X axis range.Point
atPercentY(double percentY)
Get an X-Y point based a percentage of completion of the total Y axis range.double
percentX(double x)
Determine what percentage of completion a specific X value is associated with on the segment.double
percentY(double y)
Determine what percentage of completion a specific Y value is associated with on the segment.boolean
valid(Point point)
Check to see if the provided point is valid.boolean
validX(double x)
Check to see if the provided value fits within the range of the minimum to the maximum X value.boolean
validY(double y)
Check to see if the provided value fits within the range of the minimum to the maximum Y value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
segment
The segment which will be interpolated. -
minX
private final double minXThe minimum X value contained in the segment. -
minY
private final double minYThe minimum Y value contained in the segment. -
sizeX
private final double sizeXThe size of the range between the minimum and maximum X values. -
sizeY
private final double sizeYThe size of the range between the minimum and maximum Y values. -
xRange
private final me.wobblyyyy.intra.ftc2.utils.math.Range xRangeA range of X values. -
yRange
private final me.wobblyyyy.intra.ftc2.utils.math.Range yRangeA range of Y values.
-
-
Constructor Details
-
SegmentInterpolator
Create a newSegmentInterpolator
that will interpolate the provided segment to the best of its ability.- Parameters:
segment
- the segment that should be interpolated.
-
-
Method Details
-
validX
public boolean validX(double x)Check to see if the provided value fits within the range of the minimum to the maximum X value.- Parameters:
x
- the X value to check.- Returns:
- whether or not the provided X value is within the range of the minimum and maximum values. This value is "valid" if it fits within the range and "invalid" if it does not.
-
validY
public boolean validY(double y)Check to see if the provided value fits within the range of the minimum to the maximum Y value.- Parameters:
y
- the Y value to check.- Returns:
- whether or not the provided Y value is within the range of the minimum and maximum values. This value is "valid" if it fits within the range and "invalid" if it does not.
-
valid
Check to see if the provided point is valid. Point validity is based on whether or not the respective X and Y values are "valid", which is determined using thevalidX(double)
andvalidY(double)
methods.- Parameters:
point
- the point that will be checked for validity.- Returns:
- whether or not the given point is "valid," meaning each the X and Y values are in-range.
-
percentX
public double percentX(double x)Determine what percentage of completion a specific X value is associated with on the segment.- Parameters:
x
- the X value to get the percentage of completion from.- Returns:
- the percentage of completion based on the specified X value. If the requested X value is not contained in the segment, this method will return -1, rather than a percentage of completion. If the requested value IS contained on the segment, however, this method will return a number from 0 to 1 indicating the percentage that specified value corresponds to on the segment.
-
percentY
public double percentY(double y)Determine what percentage of completion a specific Y value is associated with on the segment.- Parameters:
y
- the Y value to get the percentage of completion from.- Returns:
- the percentage of completion based on the specified Y value. If the requested Y value is not contained in the segment, this method will return -1, rather than a percentage of completion. If the requested value IS contained on the segment, however, this method will return a number from 0 to 1 indicating the percentage that specified value corresponds to on the segment.
-
atPercentX
Get an X-Y point based a percentage of completion of the total X axis range. This percentage should always fit within the range of 0 to 1.This method works by multiplying the inputted percentage value by the total size of the requested axis and then adding the minimum value of that axis to the product of the percentage and the total size. Such, this percentage will always return a real solution, assuming it fits within the defined range of 0 to 1. Anything outside of that range will be interpreted by the segment handler.
- Parameters:
percentX
- the percentage of completion to get a point from. This percentage should always fit within the range of 0 to 1, can not be negative, and should be greater than 0 in nearly all cases.- Returns:
- a point at the given percentage of completion along the
requested axis. The return value of this method is left up to the
segment's implementation of the
Segment.interpolateFromX(double)
method.
-
atPercentY
Get an X-Y point based a percentage of completion of the total Y axis range. This percentage should always fit within the range of 0 to 1.This method works by multiplying the inputted percentage value by the total size of the requested axis and then adding the minimum value of that axis to the product of the percentage and the total size. Such, this percentage will always return a real solution, assuming it fits within the defined range of 0 to 1. Anything outside of that range will be interpreted by the segment handler.
- Parameters:
percentY
- the percentage of completion to get a point from. This percentage should always fit within the range of 0 to 1, can not be negative, and should be greater than 0 in nearly all cases.- Returns:
- a point at the given percentage of completion along the
requested axis. The return value of this method is left up to the
segment's implementation of the
Segment.interpolateFromY(double)
method.
-
atPercent
Deprecated, for removal: This API element is subject to removal in a future version.This method's return values can be inaccurate for certain types of segments, specifically monotone cubic splines. Use either theatPercentX(double)
oratPercentY(double)
methods instead of this one.Get a point based on a completion percentage, 0 to 1.- Parameters:
percent
- the percentage to check for.- Returns:
- the point at the completion percentage.
-