<commit_before>/**
 * PUC-Rio 2015.2
 * INF1339 - Computação Gráfica Tridimensional
 * Professor: <NAME>
 * <NAME> 1212560
 * Trabalho - Projeto de Grafo de Cena
 */

#include <algorithm>
#include <cmath>

#include <GL/gl.h>
#include <GL/glut.h>

#include "Manipulator.h"
#include "invertMatrix.h"
#include "vec3.h"

Manipulator::Manipulator() :
    reference_{0, 0, 0},
    matrix_{1, 0, 0, 0,
            0, 1, 0, 0,
            0, 0, 1, 0,
            0, 0, 0, 1},
    inv_{1, 0, 0, 0,
         0, 1, 0, 0,
         0, 0, 1, 0,
         0, 0, 0, 1},
    operation_{Operation::kNone},
    x_{0},
    y_{0},
    v_{0, 0, 0},
    invertX_{false},
    invertY_{false} {
}

void Manipulator::Apply() {
    glTranslatef(reference_[0], reference_[1], reference_[2]);
    glMultMatrixf(matrix_.data());
    glTranslatef(-reference_[0], -reference_[1], -reference_[2]);
}

void Manipulator::ApplyInv() {
    glTranslatef(reference_[0], reference_[1], reference_[2]);
    glMultMatrixf(inv_.data());
    glTranslatef(-reference_[0], -reference_[1], -reference_[2]);
}

void Manipulator::SetReferencePoint(float x, float y, float z) {
    reference_ = {x, y, z};
}

void Manipulator::GlutMouse(int button, int state, int x, int y) {
    SetOperation<GLUT_LEFT_BUTTON, Operation::kRotation>(button, state, x, y);
    SetOperation<GLUT_RIGHT_BUTTON, Operation::kZoom>(button, state, x, y);
}
<commit_msg>Fixed the accumulation of the manipulator\'s inverse<commit_after>/**
 * PUC-Rio 2015.2
 * INF1339 - Computação Gráfica Tridimensional
 * Professor: <NAME>
 * <NAME> 1212560
 * Trabalho - Projeto de Grafo de Cena
 */

#include <algorithm>
#include <cmath>

#include <GL/gl.h>
#include <GL/glut.h>

#include "Manipulator.h"
#include "invertMatrix.h"
#include "vec3.h"

Manipulator::Manipulator() :
    reference_{0, 0, 0},
    matrix_{1, 0, 0, 0,
            0, 1, 0, 0,
            0, 0, 1, 0,
            0, 0, 0, 1},
    inv_{1, 0, 0, 0,
         0, 1, 0, 0,
         0, 0, 1, 0,
         0, 0, 0, 1},
    operation_{Operation::kNone},
    x_{0},
    y_{0},
    v_{0, 0, 0},
    invertX_{false},
    invertY_{false} {
}

void Manipulator::Apply() {
    glTranslatef(reference_[0], reference_[1], reference_[2]);
    glMultMatrixf(matrix_.data());
    glTranslatef(-reference_[0], -reference_[1], -reference_[2]);
}

void Manipulator::ApplyInv() {
    glTranslatef(-reference_[0], -reference_[1], -reference_[2]);
    glMultMatrixf(inv_.data());
    glTranslatef(reference_[0], reference_[1], reference_[2]);
}

void Manipulator::SetReferencePoint(float x, float y, float z) {
    reference_ = {x, y, z};
}

void Manipulator::GlutMouse(int button, int state, int x, int y) {
    SetOperation<GLUT_LEFT_BUTTON, Operation::kRotation>(button, state, x, y);
    SetOperation<GLUT_RIGHT_BUTTON, Operation::kZoom>(button, state, x, y);
}

{'fraction_non_alphanumeric': 0.16908383445348427, 'fraction_numerical': 0.048814998231340646, 'mean_word_length': 3.4605678233438484, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '6562264', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1067, 'n_words': 252}