<commit_before>/*
 * THE NEW CHRONOTEXT TOOLKIT: https://github.com/arielm/new-chronotext-toolkit
 * COPYRIGHT (C) 2012-2014, <NAME> ALL RIGHTS RESERVED.
 *
 * THE FOLLOWING SOURCE-CODE IS DISTRIBUTED UNDER THE MODIFIED BSD LICENSE:
 * https://github.com/arielm/new-chronotext-toolkit/blob/master/LICENSE.md
 */

/*
 * REFERENCES:
 *
 * "Adaptive Sampling of Parametric Curves" BY <NAME>
 * http://ariel.chronotext.org/dd/defigueiredo93adaptive.pdf
 */

#pragma once

#include "chronotext/path/FollowablePath.h"

#include <array>

class ASPC
{
public:
    ASPC(std::function<ci::Vec2f (float, ci::Vec2f*)> gamma, chr::FollowablePath &path, float tol = 1)
    :
    gamma(gamma),
    path(path),
    tol(tol)
    {}
    
    void segment(const ci::Vec2f &p0, const ci::Vec2f &p1, const ci::Vec2f &p2, const ci::Vec2f &p3)
    {
        in[0] = p0;
        in[1] = p1;
        in[2] = p2;
        in[3] = p3;
        
        float pt = 0;
        auto p = gamma(pt, in.data());
        
        float qt = 1;
        auto q = gamma(qt, in.data());<commit_msg>path/ASPC: ADDING STABILITY WHEN SUCCESSIVELY SAMPLING THE SAME POINTS<commit_after>/*
 * THE NEW CHRONOTEXT TOOLKIT: https://github.com/arielm/new-chronotext-toolkit
 * COPYRIGHT (C) 2012-2014, <NAME> ALL RIGHTS RESERVED.
 *
 * THE FOLLOWING SOURCE-CODE IS DISTRIBUTED UNDER THE MODIFIED BSD LICENSE:
 * https://github.com/arielm/new-chronotext-toolkit/blob/master/LICENSE.md
 */

/*
 * REFERENCES:
 *
 * "Adaptive Sampling of Parametric Curves" BY <NAME>
 * http://ariel.chronotext.org/dd/defigueiredo93adaptive.pdf
 */

#pragma once

#include "chronotext/path/FollowablePath.h"

#include <array>

class ASPC
{
public:
    ASPC(std::function<ci::Vec2f (float, ci::Vec2f*)> gamma, chr::FollowablePath &path, float tol = 1)
    :
    gamma(gamma),
    path(path),
    tol(tol)
    {
        /*
         * THE ORIGINAL ALGORITHM REQUIRES RANDOMNESS, BUT WE WANT TO AVOID THE NOISE
         * INTRODUCED BY THE SAME RANDOMNESS WHEN SUCCESSIVELY SAMPLING THE SAME POINTS
         *
         * REQUIREMENTS:
         * - MULTIPLE ASPC INSTANCES SHOULD NOT BE PROCESSED CONCURENTLY
         * - SAMPLING SHOULD TAKE PLACE RIGHT AFTER ASPC IS CREATED
         */
        srand(1);
    }
    
    void segment(const ci::Vec2f &p0, const ci::Vec2f &p1, const ci::Vec2f &p2, const ci::Vec2f &p3)
    {
        in[0] = p0;
        in[1] = p1;
        in[2] = p2;
        in[3] = p3;
        
        float pt = 0;
        auto p = gamma(pt, in.data());
        
        float qt = 1;
        auto q = gamma(qt, in.data());
{'fraction_non_alphanumeric': 0.13190661478599222, 'fraction_numerical': 0.0245136186770428, 'mean_word_length': 2.5708333333333333, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, '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': '90928', 'n_tokens_mistral': 1049, 'n_tokens_neox': 974, 'n_words': 227}