private float getValue(Deque<Vector2f> graph, float x) {
        if (graph.isEmpty()) {
            return Float.NaN;
        }
        if (x < graph.getFirst().x || x > graph.getLast().x) {
            return Float.NaN;
        }
        Vector2f prev = null;
        for (Vector2f p : graph) {
            if (prev == null || x > p.x) {
                prev = p;
            } else {
                return (x - prev.x) * (p.y - prev.y) / (p.x - prev.x) + prev.y;
            }
        }
        return Float.NaN;
    }