<commit_before>#pragma once

#include <fstream>
#include <string>
#include <cassert>
#include <vector>
#include <cmath>

class CameraPath
{
  public:
    using real = double;
    struct camera_t
    {
      real rotx,roty,rotz;
      real tranx,trany,tranz;
    };

  private:
    std::vector<camera_t> cameraVec;

  public:
    CameraPath(const std::string &fileName)
    {
      std::ifstream fin(fileName);
      int nval;
      real time;
      fin >> nval >> time;
      cameraVec.resize(nval);
      for (int i = 0; i < nval; i++)
      {
        int idum;
        fin >> idum;
        assert(idum == i+1);

        auto &cam = cameraVec[i];
        fin >> cam.rotx >> cam.roty >> cam.rotz;
        fin >> cam.tranx >> cam.trany >> cam.tranz;

        std::string order;
        fin >> order;
        assert(order == "XYZ");
      }
    }

    int nsteps() const { return cameraVec.size(); }
    const camera_t& getStep(const int step) const { return cameraVec[step%nsteps()]; }
    camera_t getRange(const real r) const
    {
      assert(r >= 0.0);
      assert(r <= 1.0);
      const real t  = r * (nsteps()-1);
      const real t0 = floor(t);
      const real t1 = t0 + 1.0;
      
      fprintf(stderr, "t0= %g  t= %g  t1= %g \n", t0,t,t1);

      const auto& c0 = cameraVec[static_cast<int>(t0)];
      const auto& c1 = cameraVec[std::min(static_cast<int>(t1),nsteps()-1)];

      const float f = (t-t0)/(t1-t0);
      auto cvt = [&](const real f0, const real f1)
      {
        return f0 + (f1-f0)*f;
      };


      camera_t cam;
      cam. rotx = cvt(c0. rotx, c1. rotx);
      cam. roty = cvt(c0. roty, c1. roty);
      cam. rotz = cvt(c0. rotz, c1. rotz);
      cam.tranx = cvt(c0.tranx, c1.tranx);
      cam.trany = cvt(c0.trany, c1.trany);
      cam.tranz = cvt(c0.tranz, c1.tranz);
     
      return cam; 
    }
};
<commit_msg>remove printf<commit_after>#pragma once

#include <fstream>
#include <string>
#include <cassert>
#include <vector>
#include <cmath>

class CameraPath
{
  public:
    using real = double;
    struct camera_t
    {
      real rotx,roty,rotz;
      real tranx,trany,tranz;
    };

  private:
    std::vector<camera_t> cameraVec;

  public:
    CameraPath(const std::string &fileName)
    {
      std::ifstream fin(fileName);
      int nval;
      real time;
      fin >> nval >> time;
      cameraVec.resize(nval);
      for (int i = 0; i < nval; i++)
      {
        int idum;
        fin >> idum;
        assert(idum == i+1);

        auto &cam = cameraVec[i];
        fin >> cam.rotx >> cam.roty >> cam.rotz;
        fin >> cam.tranx >> cam.trany >> cam.tranz;

        std::string order;
        fin >> order;
        assert(order == "XYZ");
      }
    }

    int nsteps() const { return cameraVec.size(); }
    const camera_t& getStep(const int step) const { return cameraVec[step%nsteps()]; }
    camera_t getRange(const real r) const
    {
      assert(r >= 0.0);
      assert(r <= 1.0);
      const real t  = r * (nsteps()-1);
      const real t0 = floor(t);
      const real t1 = t0 + 1.0;
      
      const auto& c0 = cameraVec[static_cast<int>(t0)];
      const auto& c1 = cameraVec[std::min(static_cast<int>(t1),nsteps()-1)];

      const float f = (t-t0)/(t1-t0);
      auto cvt = [&](const real f0, const real f1)
      {
        return f0 + (f1-f0)*f;
      };


      camera_t cam;
      cam. rotx = cvt(c0. rotx, c1. rotx);
      cam. roty = cvt(c0. roty, c1. roty);
      cam. rotz = cvt(c0. rotz, c1. rotz);
      cam.tranx = cvt(c0.tranx, c1.tranx);
      cam.trany = cvt(c0.trany, c1.trany);
      cam.tranz = cvt(c0.tranz, c1.tranz);
     
      return cam; 
    }
};

{'fraction_non_alphanumeric': 0.1549876339653751, 'fraction_numerical': 0.021434460016488046, 'mean_word_length': 2.0665543386689134, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 61, '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': '5205100', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1402, 'n_words': 332}