<commit_before>// Main logic module for ISAAC.

var ISAAC = ISAAC || { release: "1" };
ISAAC.Constants = ISAAC.Constants || {};
ISAAC.Core = ISAAC.Core || {};
ISAAC.Config = ISAAC.Config || {"updateStep" : 1, "gravConstMult" : 1, "cameraFocus" : 0};

// Units
// Distance: gigameters
// Mass: gigagrams
ISAAC.Constants.G = 6.67e-32; // in Newton square gigameters per gigagram squared.
ISAAC.Constants.timeStep = 1440; // in seconds.

ISAAC.displayProperties = function (obj) {
	for(var name in obj) {
		console.log("Property: " + name + " Value: " + obj[name]);
	}
	console.log("\n");
}

// Movement Module.
// Calls all other modules to modify an object's properties with regard to motion.
ISAAC.Core.movementModule = function (obj) {
	if(obj.switches.motionEnabled) {
		var forceChanged = ISAAC.Core.forceModule(obj);
		var accelerationChanged = ISAAC.Core.accelerationModule(obj);
		var velocityChanged = ISAAC.Core.velocityModule(obj);
		if (velocityChanged || accelerationChanged || forceChanged) {
			return true;
		}
	}
	return false;
}

// Velocity Module.
// Adjusts the position of the object, based on the velocity vector.
ISAAC.Core.velocityModule = function (obj) {
	if (obj.switches.motionEnabled) {
		obj.motion.position = ISAAC.Math.addVector(obj.motion.position, ISAAC.Math.scaleVector(obj.motion.velocity, ISAAC.Constants.timeStep));
		return true;
	}
	return false;
}

// Acceleration Module.
// Adjusts the velocity of the object, based on the acceleration vector.
ISAAC.Core.accelerationModule = function (obj) {
	if (obj.switches.accelerationEnabled) {
		//		obj.Position.velX += (obj.Position.accelX * ISAAC.Constants.timeStep);
		//		obj.Position.velY += (obj.Position.accelY * ISAAC.Constants.timeStep);
		//		obj.Position.velZ += (obj.Position.accelZ * ISAAC.Constants.timeStep);
		obj.motion.velocity = ISAAC.Math.addVector(obj.motion.velocity, ISAAC.Math.scaleVector(obj.motion.acceleration, ISAAC.Constants.timeStep));
		return true;
	}
	return false;
}

// Force Module.
// Calculates the acceleration of an object based on the resultant forces on it.
ISAAC.Core.forceModule = function(obj) {
	if (obj.switches.motionEnabled && obj.switches.forceChanged) {
		// Create a blank array for the resultant force.
		var newResultant = [0, 0, 0];
		
		// Iterate through the forces acting on the object and add them
		// to the resultant force.
		for(var force in obj.forceStore) {
			for(var i = 0; i < 3; i++) {
				newResultant[i] += obj.forceStore[force][i];
			}
		}
		
		// Set the resultant force.
		obj.resultantForce = newResultant;
		
		// Adjust the object's acceleration based on the resultant force.
		for(var i = 0; i < 3; i++) {
			obj.motion.acceleration[i] = obj.resultantForce[i] / obj.physical.mass;
		}
		
		// Reset the forceChanged switch.<commit_msg>Started second degree, fixed abstraction-obedience<commit_after>// Main logic module for ISAAC.

var ISAAC = ISAAC || { release: "1" };
ISAAC.Constants = ISAAC.Constants || {};
ISAAC.Core = ISAAC.Core || {};
ISAAC.Config = ISAAC.Config || {"updateStep" : 1, "gravConstMult" : 1, "cameraFocus" : 0};

// Units
// Distance: gigameters
// Mass: gigagrams
ISAAC.Constants.G = 6.67e-32; // in Newton square gigameters per gigagram squared.
ISAAC.Constants.timeStep = 1440; // in seconds.

ISAAC.displayProperties = function (obj) {
	for(var name in obj) {
		console.log("Property: " + name + " Value: " + obj[name]);
	}
	console.log("\n");
}

// Movement Module.
// Calls all other modules to modify an object's properties with regard to motion.
ISAAC.Core.movementModule = function (obj) {
	if(obj.switches.motionEnabled) {
		var forceChanged = ISAAC.Core.forceModule(obj);
		var accelerationChanged = ISAAC.Core.accelerationModule(obj);
		var velocityChanged = ISAAC.Core.velocityModule(obj);
		if (velocityChanged || accelerationChanged || forceChanged) {
			return true;
		}
	}
	return false;
}

// Velocity Module.
// Adjusts the position of the object, based on the velocity vector.
ISAAC.Core.velocityModule = function (obj) {
	if (obj.switches.motionEnabled) {
		firstDegreeTerm = ISAAC.Math.scaleVector(obj.motion.velocity, ISAAC.Constants.timeStep);

		//This is certainly the wrong equation (causes closer planets to spiral into the sun)
		//secondDegreeTerm = ISAAC.Math.scaleVector(obj.motion.acceleration, ISAAC.Math.sqr(ISAAC.Constants.timeStep));

		secondDegreeTerm = [0, 0, 0];
		obj.motion.position = ISAAC.Math.addVector(obj.motion.position, ISAAC.Math.addVector(firstDegreeTerm, secondDegreeTerm));
		return true;
	}
	return false;
}

// Acceleration Module.
// Adjusts the velocity of the object, based on the acceleration vector.
ISAAC.Core.accelerationModule = function (obj) {
	if (obj.switches.accelerationEnabled) {
		//		obj.Position.velX += (obj.Position.accelX * ISAAC.Constants.timeStep);
		//		obj.Position.velY += (obj.Position.accelY * ISAAC.Constants.timeStep);
		//		obj.Position.velZ += (obj.Position.accelZ * ISAAC.Constants.timeStep);
		obj.motion.velocity = ISAAC.Math.addVector(obj.motion.velocity, ISAAC.Math.scaleVector(obj.motion.acceleration, ISAAC.Constants.timeStep));
		return true;
	}
	return false;
}

// Force Module.
// Calculates the acceleration of an object based on the resultant forces on it.
ISAAC.Core.forceModule = function(obj) {
	if (obj.switches.motionEnabled && obj.switches.forceChanged) {
		// Create a blank array for the resultant force.
		var newResultant = [0, 0, 0];
		
		// Iterate through the forces acting on the object and add them
		// to the resultant force.
		for(var force in obj.forceStore) {
				newResultant = ISAAC.Math.addVector(newResultant, obj.forceStore[force]);
		}
		
		// Set the resultant force.
		obj.resultantForce = newResultant;
		
		// Adjust the object's acceleration based on the resultant force.
		obj.motion.acceleration = ISAAC.Math.scaleVector(obj.resultantForce, 1/obj.physical.mass);
		
		// Reset the forceChanged switch.
{'fraction_non_alphanumeric': 0.1295826997803683, 'fraction_numerical': 0.0067578982936306806, 'mean_word_length': 3.8925619834710745, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '7607630', 'n_tokens_mistral': 2166, 'n_tokens_neox': 1913, 'n_words': 492}