<commit_before>use graphics::math::Matrix2d;
use std::f64;
use vec2::Vec2;

#[derive(Copy, Clone)]
pub struct Transform {
    position: Vec2,
    rotation: f64,
}

impl Transform {
    pub fn new() -> Transform {
        // zero format for Matrix2d. Reverse engineered from Piston.
        // x = 0, y = 0, rotation = 0
        Transform {
            position: Vec2 { x: 0.0, y: 0.0 },
            rotation: 0.0,
        }
    }

    pub fn from_x_y_rotation(x: f64, y: f64, rotation: f64) -> Transform {
        let mut value = Transform::new();
        *value.mut_x() = x;
        *value.mut_y() = y;
        *value.mut_rotation() = rotation;
        value
    }

    pub fn position(&self) -> &Vec2 {
        &self.position
    }

    pub fn mut_position(&mut self) -> &mut Vec2 {
        &mut self.position
    }

    pub fn x(&self) -> &f64 {
        &self.position.x
    }

    pub fn y(&self) -> &f64 {
        &self.position.y
    }

    pub fn rotation(&self) -> &f64 {
        &self.rotation
    }

    pub fn mut_x(&mut self) -> &mut f64 {
        &mut self.position.x
    }

    pub fn mut_y(&mut self) -> &mut f64 {
        &mut self.position.y
    }

    pub fn mut_rotation(&mut self) -> &mut f64 {
        self.rotation %= 2.0 * f64::consts::PI;
        &mut self.rotation
    }

    pub fn forward_vec2(&self) -> Vec2 {
        Vec2 {
            x: -self.rotation().sin(),
            y: self.rotation().cos(),
        }
    }

    pub fn right_vec2(&self) -> Vec2 {
        Vec2 {
            x: self.rotation().cos(),
            y: -self.rotation().sin(),
        }
    }
}

// Raw format reverse engineered from Piston internals.<commit_msg>Woops, fix the right vec optimization.<commit_after>use graphics::math::Matrix2d;
use std::f64;
use vec2::Vec2;

#[derive(Copy, Clone)]
pub struct Transform {
    position: Vec2,
    rotation: f64,
}

impl Transform {
    pub fn new() -> Transform {
        // zero format for Matrix2d. Reverse engineered from Piston.
        // x = 0, y = 0, rotation = 0
        Transform {
            position: Vec2 { x: 0.0, y: 0.0 },
            rotation: 0.0,
        }
    }

    pub fn from_x_y_rotation(x: f64, y: f64, rotation: f64) -> Transform {
        let mut value = Transform::new();
        *value.mut_x() = x;
        *value.mut_y() = y;
        *value.mut_rotation() = rotation;
        value
    }

    pub fn position(&self) -> &Vec2 {
        &self.position
    }

    pub fn mut_position(&mut self) -> &mut Vec2 {
        &mut self.position
    }

    pub fn x(&self) -> &f64 {
        &self.position.x
    }

    pub fn y(&self) -> &f64 {
        &self.position.y
    }

    pub fn rotation(&self) -> &f64 {
        &self.rotation
    }

    pub fn mut_x(&mut self) -> &mut f64 {
        &mut self.position.x
    }

    pub fn mut_y(&mut self) -> &mut f64 {
        &mut self.position.y
    }

    pub fn mut_rotation(&mut self) -> &mut f64 {
        self.rotation %= 2.0 * f64::consts::PI;
        &mut self.rotation
    }

    pub fn forward_vec2(&self) -> Vec2 {
        Vec2 {
            x: -self.rotation().sin(),
            y: self.rotation().cos(),
        }
    }

    pub fn right_vec2(&self) -> Vec2 {
        Vec2 {
            x: self.rotation().cos(),
            y: self.rotation().sin(),
        }
    }
}

// Raw format reverse engineered from Piston internals.
{'fraction_non_alphanumeric': 0.14528639618138425, 'fraction_numerical': 0.029236276849642005, 'mean_word_length': 1.6910112359550562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '3062790', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1126, 'n_words': 292}