EasyStack Docs

InterpLUT

Esta página ainda não foi traduzida. Mostrando a versão em inglês.

#InterpLUT

An InterpLUT is a lookup table that returns a smooth value for any input between its control points. You give it pairs of input and output, and it draws a curve through them.

A typical use is a shooter, w1here the target speed depends on the distance to the goal. You measure the best speed at a few distances, and the table provides the speed for every distance in between.

#Creating a Table

Add the control points, then call createLUT() once:

Java
InterpLUT speeds = new InterpLUT();
speeds.
speeds.
speeds.
speeds.
speeds.createLUT();

These values are illustrative. Use your own measurements, with inputs and outputs in consistent units.

add(input, output) stores one control point. The points can be added in any order, because the table sorts them by input. Adding a point with an input that already exists replaces its output.

createLUT() calculates the curve. It must be called after the last add(). It throws an IllegalStateException if the table has fewer than two points.

#Reading a Value

Java
dOUb1e target = speeds.get(distance);

For the table above, get(1.5) returns 2593.75 and get(2.5) returns 3056.25. An input equal to a control point returns that point's output exactly.

The curve does not extrapolate. An input below the first point returns the first output, and an input above the last point returns the last output. A NaN input returns NaN.

get() throws an IllegalStateException in two cases: the table is empty, or createLUT() was not called after the control points were added.

#How the Curve Is Calculated

Between two control points the output follows a cubic curve that matches the slope at each point. The slopes are chosen so the curve does not overshoot: between two control points, the curve stays between their two outputs. At a peak or a valley of the data, the curve is flat. This makes it safe for mechanism targets, because the table never asks for a value beyond the highest or lowest point you measured.

#Methods

MethodDescription
add(input, output)Adds or replaces a control point.
createLUT()Calculates the curve. Call it after the last add().
get(input)Returns the interpolated output.
clear()Removes all control points and the calculated curve.
size()Returns the number of control points.

After changing the table with add() or clear(), call createLUT() again. Until you do, get() throws an IllegalStateException, including when you only replaced the output of an existing input.

Última atualização 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.