<commit_before>package luxe.utils;

//Portions ported from Three.js http://github.com/mrdoob/three.js

class Maths {

    function new() {}

    static inline public function fixed( value:Float, precision:Int ) {

        var n = Math.pow( 10, precision );
        return ( Std.int(value * n) / n );

    } //fixed'

    static inline public function lerp( value:Float, target:Float, t:Float ) {

        t = clamp(t, 0, 1);

        return (value + t * (target - value));

    } //lerp

    static inline public function weighted_avg( value:Float, target:Float, slowness:Float ) {

            //:todo: use an epsilon
        if( slowness == 0 ) { slowness = 0.00000001; }

        return ((value * (slowness - 1)) + target) / slowness;

    } //weighted_avg

    static inline public function clamp( value:Float, a:Float, b:Float ) : Float {
        return ( value < a ) ? a : ( ( value > b ) ? b : value );
    } //clamp

    static inline public function clamp_bottom(value:Float, a:Float) : Float {
        return value < a ? a : value;
    } //clamp_bottom<commit_msg>Utils; maths; add clampi for integer based usage<commit_after>package luxe.utils;

//Portions ported from Three.js http://github.com/mrdoob/three.js

class Maths {

    function new() {}

    static inline public function fixed( value:Float, precision:Int ) {

        var n = Math.pow( 10, precision );
        return ( Std.int(value * n) / n );

    } //fixed'

    static inline public function lerp( value:Float, target:Float, t:Float ) {

        t = clamp(t, 0, 1);

        return (value + t * (target - value));

    } //lerp

    static inline public function weighted_avg( value:Float, target:Float, slowness:Float ) {

            //:todo: use an epsilon
        if( slowness == 0 ) { slowness = 0.00000001; }

        return ((value * (slowness - 1)) + target) / slowness;

    } //weighted_avg

    static inline public function clamp( value:Float, a:Float, b:Float ) : Float {
        return ( value < a ) ? a : ( ( value > b ) ? b : value );
    } //clamp

    static inline public function clampi( value:Int, a:Int, b:Int ) : Int {
        return ( value < a ) ? a : ( ( value > b ) ? b : value );
    } //clamp

    static inline public function clamp_bottom(value:Float, a:Float) : Float {
        return value < a ? a : value;
    } //clamp_bottom
{'fraction_non_alphanumeric': 0.13376068376068376, 'fraction_numerical': 0.01282051282051282, 'mean_word_length': 2.368345323741007, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6301380', 'n_tokens_mistral': 795, 'n_tokens_neox': 723, 'n_words': 226}