Class Spline
java.lang.Object
me.wobblyyyy.pathfinder.trajectory.Spline
- All Implemented Interfaces:
- Segment
public class Spline extends java.lang.Object implements Segment
Ahh... splines. Basically gay lines. I swear I'm not homophobic, I like men
 too. Anyways. Straight lines are very linear and very boring. Splines, on
 the other hand, are basically straight lines that aren't at all straight -
 rather, they curve. Splines are incredibly useful in making complex movement
 trajectories and profiles. Unlike regular lines, splines, as you know, have
 an element of curvature. This element of curvature allows for your robot to
 continually move without ever having to come to a stop or a hard direction
 change. Splines themselves are representations of a concept, not fully
 fledged implementations of a trajectory following algorithm.
 
Splines, or at least these splines, make use of the Fritsch-Carlson method for computing internal spline parameters. This method isn't incredibly computationally expensive, but as a best practice, it's suggested that you do as little runtime execution of spline initialization.
 Interpolation is handled by yet another rather complex algorithm that nobody
 quite understands - including me, probably. Anyways, if you really are quite
 sincerely interested in learning how spline interpolation works, you can
 go check out the SplineInterpolator class - that has all the cool
 and sexy math you might want to look at.
 
- Since:
- 0.3.0
- Author:
- Colin Robertson
- 
Field SummaryFields Modifier and Type Field Description private me.wobblyyyy.edt.DynamicArray<Angle>anglesAn array of all of the angles contained on the spline's path.private SplineInterpolatorinterpolatorThe internal spline interpolator.private booleanisInvertedIs the spline's internal interpolator inverted?private me.wobblyyyy.edt.StaticArray<HeadingPoint>pointsA set of each of the points that the spline should hit.private doublexMaximumThe maximum X value of the spline.private doublexMinimumThe minimum X value of the spline.private doubleyMaximumThe maximum Y value of the spline.private doubleyMinimumThe minimum Y value of the spline.
- 
Constructor SummaryConstructors Constructor Description Spline(me.wobblyyyy.edt.Arrayable<HeadingPoint> points)Create a newSplinethat will hit each of the required points.
- 
Method SummaryModifier and Type Method Description AngleangleAt(Point point)Get the angle which the robot should be facing at the given trajectory.Pointend()Get the point where the segment ends.private java.util.ArrayList<java.lang.Double>fromDynamicArray(me.wobblyyyy.edt.DynamicArray<java.lang.Double> array)Convert anDynamicArrayinto anArrayList.PointinterpolateFromX(double xValue)Get a point from the segment based on an X value.PointinterpolateFromY(double yValue)Get a point from the segment based on an Y value.Pointmaximum()Get a combination of the maximum X and Y values for the segment.Pointminimum()Get a combination of the minimum X and Y values for the segment.private static booleanonlyIncreasing(java.util.ArrayList<java.lang.Double> values)Check to see if anArrayListonly has a sequence of increasing values - used for spline inversion.Pointstart()Get the point where the segment starts.java.lang.StringtoString()Convert the spline to a string representation of the spline.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
- 
Field Details- 
interpolatorThe internal spline interpolator. All of the hard math behind splines is handled in a separate class as to reduce code clutter and make theSplineclass a bit more readable, especially for those without much experience in building splines.
- 
pointsA set of each of the points that the spline should hit. This is used mostly for metadata about the spline.
- 
anglesAn array of all of the angles contained on the spline's path. TODO implement angles
- 
xMinimumprivate double xMinimumThe minimum X value of the spline.
- 
yMinimumprivate double yMinimumThe minimum Y value of the spline.
- 
xMaximumprivate double xMaximumThe maximum X value of the spline.
- 
yMaximumprivate double yMaximumThe maximum Y value of the spline.
- 
isInvertedprivate final boolean isInvertedIs the spline's internal interpolator inverted?
 
- 
- 
Constructor Details- 
SplineCreate a newSplinethat will hit each of the required points. Splines are created so that they hit each and every one of the target points, meaning that if you tell the robot to pass through (10, 10), the robot will pass through (10, 10) no matter what.- Parameters:
- points- a container that contains each of the required points. Each and every one of these points will be passed through directly by the spline computational system, meaning that the robot will go exactly where you tell it to go.
 
 
- 
- 
Method Details- 
onlyIncreasingprivate static boolean onlyIncreasing(java.util.ArrayList<java.lang.Double> values)Check to see if anArrayListonly has a sequence of increasing values - used for spline inversion.- Parameters:
- values- the values to check.
- Returns:
- whether or not the values exclusively sequentially increase.
 
- 
fromDynamicArrayprivate java.util.ArrayList<java.lang.Double> fromDynamicArray(me.wobblyyyy.edt.DynamicArray<java.lang.Double> array)Convert anDynamicArrayinto anArrayList.- Parameters:
- array- the- DynamicArrayto convert.
- Returns:
- the ArrayListthat's been created.
 
- 
interpolateFromXGet a point from the segment based on an X value. This point should fit within the bounds of the segment and should be represented partially by the provided value, which provides a basis for interpolation from there.- Specified by:
- interpolateFromXin interface- Segment
- Parameters:
- xValue- the value that the segment should interpolate from. This means, in essence, that the segment should determine the nearest possible point to the requested X value.
- Returns:
- an interpolated point based on an inputted value. This point has no regard for heading - rather, it's a simple and plain point that can be used for following the trajectory or just figuring out where a certain value on the trajectory lies.
 
- 
interpolateFromYGet a point from the segment based on an Y value. This point should fit within the bounds of the segment and should be represented partially by the provided value, which provides a basis for interpolation from there.- Specified by:
- interpolateFromYin interface- Segment
- Parameters:
- yValue- the value that the segment should interpolate from. This means, in essence, that the segment should determine the nearest possible point to the requested Y value.
- Returns:
- an interpolated point based on an inputted value. This point has no regard for heading - rather, it's a simple and plain point that can be used for following the trajectory or just figuring out where a certain value on the trajectory lies.
 
- 
angleAtGet the angle which the robot should be facing at the given trajectory. This angle is handled separately from the interpolation methods to increase the degree of flexibility theSegmentinterface will provide both internally and externally.- Specified by:
- angleAtin interface- Segment
- Parameters:
- point- the point that will serve as a basis for fetching the desired robot heading.
- Returns:
- the most closely interpolated heading/angle at a given point. This angle typically corresponds to how far along the segment the robot has travelled, but it's up to the implementations of the segment class to decide how exactly this is handled. Yay interfaces!
 
- 
minimumGet a combination of the minimum X and Y values for the segment. This point is used to reduce primitive clutter - instead of returning an individual X and Y double, we can return a single point that represents our requested information.
- 
maximumGet a combination of the maximum X and Y values for the segment. This point is used to reduce primitive clutter - instead of returning an individual X and Y double, we can return a single point that represents our requested information.
- 
toStringpublic java.lang.String toString()Convert the spline to a string representation of the spline.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- the interpolator's representation of the spline in the very readable String form.
 
- 
startGet the point where the segment starts. This is defined as the position that represents 0 percent of the segment's completion.
- 
endGet the point where the segment ends. This is defined as the position that represents 100 percent of the segment's completion.
 
-