<commit_before>/*
 * Particle.cpp
 *
 *  Created on: Mar 25, 2017
 *      Author: vgomeniuk
 */

#include "Particle.h"
#include <math.h>
#include <stdlib.h>

namespace particleapp {

Particle::Particle() : m_x(0), m_y(0) {
	this->init();
}
void Particle::init(){
	m_direction = (2 * M_PI * rand()) / RAND_MAX;
	m_speed = (0.04 * rand()) / RAND_MAX;
	m_speed *= m_speed;  // Differentiate particles distribution
}

void Particle::update(int delta_time) {
	m_direction += delta_time * 0.0003;

	double xspeed = m_speed * cos(m_direction);
	double yspeed = m_speed * sin(m_direction);

	m_x += xspeed * delta_time;
	m_y += yspeed * delta_time;

	// In case particle goes out local scope => initialize new speed / direction
	if (m_x < -1 || m_x > 1 || m_y < -1 || m_y > 1){
		this->init();
		return;
	}
	// Randomly initialize new speed / direction with probability ~1:100
	if (rand() < (RAND_MAX / 100)){
		this->init();
	}
}

} /* namespace particleapp */<commit_msg>minor update<commit_after>/*
 * Particle.cpp
 *
 *  Created on: Mar 25, 2017
 *      Author: vgomeniuk
 */

#include "Particle.h"
#include <math.h>
#include <stdlib.h>

namespace particleapp {

Particle::Particle() : m_x(0), m_y(0), m_speed(0), m_direction(0) {
	this->init();
}
void Particle::init(){
	m_direction = (2 * M_PI * rand()) / RAND_MAX;  // In local scope [-1:1]
	m_speed = (0.04 * rand()) / RAND_MAX;
	m_speed *= m_speed;  // Differentiate particles distribution
}

void Particle::update(int delta_time) {
	// Shift direction a bit each frame
	m_direction += delta_time * 0.0003;

	// Calculate position using speed and direction
	double xspeed = m_speed * cos(m_direction);
	double yspeed = m_speed * sin(m_direction);

	m_x += xspeed * delta_time;
	m_y += yspeed * delta_time;

	// In case particle goes out of local scope => initialize new speed / direction
	if (m_x < -1 || m_x > 1 || m_y < -1 || m_y > 1){
		this->init();
		return;
	}
	// Randomly initialize new speed / direction with probability ~1:100
	if (rand() < (RAND_MAX / 100)){
		this->init();
	}
}

} /* namespace particleapp */
{'fraction_non_alphanumeric': 0.15733590733590733, 'fraction_numerical': 0.02895752895752896, 'mean_word_length': 3.566079295154185, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5476407', 'n_tokens_mistral': 822, 'n_tokens_neox': 762, 'n_words': 208}