<commit_before>//Get mouse position as an "unprojected" point in 3D space

#include <sys/time.h>

#include "vsr_cga3D.h"   
#include "vsr_GLVimpl.h"
#include "vsr_ncube.h"

using namespace vsr;
using namespace std;

static long timeGetTime( void )
{
    struct timeval now; //, res;

    gettimeofday(&now, 0);

    return (long)((now.tv_sec*1000) + (now.tv_usec/1000));
}

/*template< class B >
auto nrot( const B& b) -> decltype( B() + 1 ) {         
    VT c = sqrt(-(b.wt()));
    VT sc = -sin(c);

    if (c != 0) {
        sc /= c;
    }
   
    return (b*sc) + cos(c);
} */

struct MyApp : App {    

    Pnt mouse;
    Lin ray;
    long to;
    float fTime;


    MyApp(Window * win ) : App(win) {
        to = timeGetTime();
        scene.camera.pos(0, 0, 10); 
    }

    void getMouse(){
        auto tv = interface.vd().ray; 
        Vec z (tv[0], tv[1], tv[2] );
        auto tm = interface.mouse.projectMid;
        ray = Round::point( tm[0], tm[1], tm[2] ) ^ z ^ Inf(1); 
        mouse = Round::point( ray,  Ori(1) );  
    }

    void drawCube(Vec vecPosition, float fRadius) {
        vector<Vec> proj;
        static const int DIM = 4;

        NCube<DIM> cube;

        auto& res = cube.roots; 

        for (auto& i : res) {
            // For rotation:
            //EGAMV<DIM, MV<24,12> > b(1,.01);
            //i = i.sp(nrot(b));
            
            auto tmp = Proj<DIM>::Ortho<3>(i);
            proj.push_back(tmp);
        }

        
        for (auto i : cube.edges) {
            gfx::Glyph::Line(proj[i.a], proj[i.b]);
        }
    }

    virtual void onDraw() {
        fTime = 0.001f * (timeGetTime() - to);
        getMouse();

        Point a = Ro::point(0, 0, 0);
        Draw(a);

        auto foo = Vec(-0.5, 0.5, -0.5);
        Biv rotX(fTime, 0, 0);

        auto sbtl = Ro::sphere(foo.rot(rotX), 0.2);
        Draw(sbtl);
        auto sftl = Ro::sphere(Vec(-0.5, 0.5, 0.5), 0.2);
        Draw(sftl);
        auto sbtr = Ro::sphere(Vec(0.5, 0.5, -0.5), 0.2);
        Draw(sbtr);
        auto sftr = Ro::sphere(Vec(0.5, 0.5, 0.5), 0.2);
        Draw(sftr);

        auto sbbl = Ro::sphere(Vec(-0.5, -0.5, -0.5), 0.2);
        Draw(sbbl);
        auto sfbl = Ro::sphere(Vec(-0.5, -0.5, 0.5), 0.2);
        Draw(sfbl);
        auto sbbr = Ro::sphere(Vec(0.5, -0.5, -0.5), 0.2);
        Draw(sbbr);
        auto sfbr = Ro::sphere(Vec(0.5, -0.5, 0.5), 0.2);
        Draw(sfbr);

        drawCube(Vec(0, 0, 0), 2.0f);
    }
};


MyApp * app;

int main() {
    GLV glv(0, 0);
    Window * win = new Window(500, 500, "Funkeeh stuff!", &glv);
    app = new MyApp(win); 
    glv << *app;

    Application::run();

    return 0;
}<commit_msg>Implementing of main project goal<commit_after>//Get mouse position as an "unprojected" point in 3D space

#include <sys/time.h>

#include "vsr_cga3D.h"   
#include "vsr_GLVimpl.h"
#include "vsr_ncube.h"

using namespace vsr;
using namespace std;

#pragma GCC diagnostic ignored "-Wswitch"

static long timeGetTime( void )
{
    struct timeval now; //, res;

    gettimeofday(&now, 0);

    return (long)((now.tv_sec*1000) + (now.tv_usec/1000));
}

struct MyApp : App {    
    static const int DIM = 4;

    Pnt mouse;
    Lin ray;
    long to;
    float fTime;
    NCube<DIM> cube;
    vector<Vec> vecCube;
    Biv bivRotation;
    bool bDoAnimate;
    bool bDrawSpheresAsWireframe;
    bool bDrawCubeAsLines;
    enum CubeRenderModes { NORMAL, LINES };
    enum CubeRenderModes cubeRenderMode;
    double dFps;
    Window* pWindow;

    MyApp(Window * win ) : App(win) {
        to = timeGetTime();
        scene.camera.pos(0, 0, 4); 
        setupCube();
        cubeRenderMode = NORMAL;
        bDoAnimate = true;
        bDrawSpheresAsWireframe = false;
        bDrawCubeAsLines = false;
        pWindow = win;
    }

    ~MyApp() {
        if (pWindow) {
            delete pWindow;
        }
    }

    virtual void initGui() {
        gui(bDoAnimate, "Toggle animation");
        gui(bDrawSpheresAsWireframe, "Draw spheres wireframed");
        gui(bDrawCubeAsLines, "Draw cube using lines within GA");
    }

    void setupCube() {
        for (auto& i : cube.roots) {
            auto tmp = Proj<DIM>::Ortho<3>(i);
            vecCube.push_back(tmp);
        }
    }

    void getMouse(){
        auto tv = interface.vd().ray; 
        Vec z (tv[0], tv[1], tv[2] );
        auto tm = interface.mouse.projectMid;
        ray = Round::point( tm[0], tm[1], tm[2] ) ^ z ^ Inf(1); 
        mouse = Round::point( ray,  Ori(1) );  
    }

    void drawCube(Vec vecPosition, float fRadius) {
        for (auto edge : cube.edges) {
            gfx::Glyph::Line(
                vecCube[edge.a].rot(bivRotation),
                vecCube[edge.b].rot(bivRotation)
            );
        }
    }

    void drawGACube(Vec vecPosition, float fRadius) {
        Point bottomLeftFront = Ro::point(-fRadius, -fRadius, fRadius);
        Point bottomRightFront = Ro::point(fRadius, -fRadius, fRadius);

        Point topLeftFront = Ro::point(-fRadius, fRadius, fRadius);
        Point topRightFront = Ro::point(fRadius, fRadius, fRadius);

        Point bottomLeftBack = Ro::point(-fRadius, -fRadius, -fRadius);
        Point bottomRightBack = Ro::point(fRadius, -fRadius, -fRadius);

        Point topLeftBack = Ro::point(-fRadius, fRadius, -fRadius);
        Point topRightBack = Ro::point(fRadius, fRadius, -fRadius);

        Line lineTopBack = Fl::line(topLeftBack.rot(bivRotation), topRightBack.rot(bivRotation));
        Line lineLeftBack = Fl::line(topLeftBack.rot(bivRotation), bottomLeftBack.rot(bivRotation));
        Line lineRightBack = Fl::line(topRightBack.rot(bivRotation), bottomRightBack.rot(bivRotation));
        Line lineBottomBack = Fl::line(bottomLeftBack.rot(bivRotation), bottomRightBack.rot(bivRotation));

        Line lineTopLeft = Fl::line(topLeftBack.rot(bivRotation), topLeftFront.rot(bivRotation));
        Line lineTopRight = Fl::line(topRightBack.rot(bivRotation), topRightFront.rot(bivRotation));
        Line lineBottomLeft = Fl::line(bottomLeftBack.rot(bivRotation), bottomLeftFront.rot(bivRotation));
        Line lineBottomRight = Fl::line(bottomRightBack.rot(bivRotation), bottomRightFront.rot(bivRotation));

        Line lineTopFront = Fl::line(topLeftFront.rot(bivRotation), topRightFront.rot(bivRotation));
        Line lineLeftFront = Fl::line(topLeftFront.rot(bivRotation), bottomLeftFront.rot(bivRotation));
        Line lineRightFront = Fl::line(topRightFront.rot(bivRotation), bottomRightFront.rot(bivRotation));
        Line lineBottomFront = Fl::line(bottomLeftFront.rot(bivRotation), bottomRightFront.rot(bivRotation));

        Draw(lineTopBack);
        Draw(lineLeftBack);
        Draw(lineRightBack);
        Draw(lineBottomBack);

        Draw(lineTopLeft);
        Draw(lineTopRight);
        Draw(lineBottomLeft);
        Draw(lineBottomRight);

        Draw(lineTopFront);
        Draw(lineLeftFront);
        Draw(lineRightFront);
        Draw(lineBottomFront);
    }

    virtual void onDraw() {
        std::stringstream strTitle;
        strTitle << "Funkeeh stuff - FPS: ";
        strTitle << pWindow->fpsActual();
        pWindow->title(strTitle.str());

        float fSphereRadius = 0.2;

        if (bDrawSpheresAsWireframe) {
            fSphereRadius *= (-1);
        }

        if (bDoAnimate) {
            fTime = (timeGetTime() - to);
        }
        else {
            fTime = 0.0f;
        }

        getMouse();
        bivRotation = Biv(sinf(fTime * 0.001f), 0, cosf(fTime * 0.001f));

        
        // Individual rotation of the spheres...
        glRotatef(fTime * 0.1f, 1.0f, 0.0f, 1.0f);

        auto sbtl = Ro::sphere(Vec(-0.5, 0.5, -0.5).rot(bivRotation), fSphereRadius);
        Draw(sbtl);
        auto sftl = Ro::sphere(Vec(-0.5, 0.5, 0.5).rot(bivRotation), fSphereRadius);
        Draw(sftl);
        auto sbtr = Ro::sphere(Vec(0.5, 0.5, -0.5).rot(bivRotation), fSphereRadius);
        Draw(sbtr);
        auto sftr = Ro::sphere(Vec(0.5, 0.5, 0.5).rot(bivRotation), fSphereRadius);
        Draw(sftr);

        auto sbbl = Ro::sphere(Vec(-0.5, -0.5, -0.5).rot(bivRotation), fSphereRadius);
        Draw(sbbl);
        auto sfbl = Ro::sphere(Vec(-0.5, -0.5, 0.5).rot(bivRotation), fSphereRadius);
        Draw(sfbl);
        auto sbbr = Ro::sphere(Vec(0.5, -0.5, -0.5).rot(bivRotation), fSphereRadius);
        Draw(sbbr);
        auto sfbr = Ro::sphere(Vec(0.5, -0.5, 0.5).rot(bivRotation), fSphereRadius);
        Draw(sfbr);

        if (bDrawCubeAsLines) {
            drawGACube(Vec(0, 0, 0), 0.5f);
        }
        else {
            drawCube(Vec(0, 0, 0), 0.5f);
        }
    }
};


MyApp * app;

int main() {
    GLV glv(0, 0);
    
    Window * win = new Window(1024, 768, "Funkeeh stuff!", &glv);
    
    app = new MyApp(win); 
    app->initGui();

    glv << *app;

    Application::run();

    return 0;
}
{'fraction_non_alphanumeric': 0.15319675821701936, 'fraction_numerical': 0.02645204862674471, 'mean_word_length': 2.2581591492482582, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 20, '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': '904489', 'n_tokens_mistral': 3368, 'n_tokens_neox': 3175, 'n_words': 659}