<commit_before>#pragma once

#include <cmath>
#include <functional>

namespace Tangram {

using EaseCb = std::function<void (float)>;

enum class EaseType : char {
    linear = 0,
    cubic,
    quint,
    sine,
};

template<typename T>
T ease(T _start, T _end, float _t, EaseType _e) {
    float f = _t;
    switch (_e) {
        case EaseType::cubic: f = (-2 * f + 3) * f * f; break;
        case EaseType::quint: f = (6 * f * f - 15 * f + 10) * f * f * f; break;
        case EaseType::sine: f = 0.5 - 0.5 * cos(M_PI * f); break;
        default: break;
    }
    return _start * (1 - f) + _end * f;
}
<commit_msg>Better numerical stability for easing<commit_after>#pragma once

#include <cmath>
#include <functional>

namespace Tangram {

using EaseCb = std::function<void (float)>;

enum class EaseType : char {
    linear = 0,
    cubic,
    quint,
    sine,
};

template<typename T>
T ease(T _start, T _end, float _t, EaseType _e) {
    float f = _t;
    switch (_e) {
        case EaseType::cubic: f = (-2 * f + 3) * f * f; break;
        case EaseType::quint: f = (6 * f * f - 15 * f + 10) * f * f * f; break;
        case EaseType::sine: f = 0.5 - 0.5 * cos(M_PI * f); break;
        default: break;
    }
    return _start + (_end - _start) * f;
}

{'fraction_non_alphanumeric': 0.14853057982525814, 'fraction_numerical': 0.019857029388403495, 'mean_word_length': 2.4146341463414633, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6112782', 'n_tokens_mistral': 517, 'n_tokens_neox': 497, 'n_words': 153}