Last active
March 25, 2020 11:56
-
-
Save sienki-jenki/cde331b04422148939f0d3debc669d6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function g(t, y) { | |
let g = []; | |
// return [y[2], y[3], -y[0] / Math.pow(y[0] * y[0] + y[1] * y[1], 1.5)+ (mu*alpha*y[1])/mass(t), -y[1] / Math.pow(y[0] * y[0] + y[1] * y[1], 1.5)+ (mu*alpha*y[1])/mass(t)]; | |
for (let c = 0; c < particles; c++) { | |
let temp = c * 4; | |
let y1, y2, y3, y4; | |
y1 = y[2 + temp]; | |
y2 = y[3 + temp]; | |
y3 = -y[temp]; | |
y4 = -y[1 + temp]; | |
//console.log(y) | |
for (let a = 0; a < particles; a++) { | |
if (a === c) { | |
continue; | |
} | |
y3 += ((y[temp] - y[a * 4]) / (Math.pow(Math.pow(y[temp] - y[a * 4], 2) + Math.pow(y[1 + temp] - y[1 + a * 4], 2), 3 / 2))); | |
y4 += ((y[1 + temp] - y[1 + a * 4]) / (Math.pow(Math.pow(y[temp] - y[a * 4], 2) + Math.pow(y[1 + temp] - y[1 + a * 4], 2), 3 / 2))); | |
} | |
//g = [...g, y[2 + temp], y[3 + temp], -y[temp], -y[1 + temp]] | |
g = [...g, y1, y2, y3, y4]; | |
//console.log(g); | |
} | |
//console.log(g) | |
//return [y[1], -a * Math.pow(gamma, 2) * Math.cos(gamma * t) * Math.sin(y[0]) - Math.sin(y[0])]; | |
//return [y[1], -a * Math.sin(y[0]) + Math.pow(gamma, 2) * Math.cos(gamma * t) * Math.cos(y[0])]; | |
//return [y[1], -(a + Math.pow(gamma, 2) * Math.cos(gamma * t)) * Math.sin(y[0])]; | |
//return [y[0], y[1]]; | |
return g; | |
/*return [y[1], | |
(-y[0] / Math.pow(Math.pow(y[0], 2) + Math.pow(y[2], 2), 3.0 / 2.0)) - masa * (y[0] - y[4]) / Math.pow((Math.pow(y[0] - y[4], 2) + Math.pow(y[2] - y[6], 2)), 3.0 / 2.0), | |
y[3], | |
(-y[2] / Math.pow(Math.pow(y[0], 2) + Math.pow(y[2], 2), 3.0 / 2.0)) - masa * (y[2] - y[6]) / Math.pow((Math.pow(y[0] - y[4], 2) + Math.pow(y[2] - y[6], 2)), 3.0 / 2.0), | |
y[5], | |
(-y[4] / Math.pow(Math.pow(y[4], 2) + Math.pow(y[6], 2), 3.0 / 2.0)) - masaa * (y[4] - y[0]) / Math.pow((Math.pow(y[0] - y[4], 2) + Math.pow(y[2] - y[6], 2)), 3.0 / 2.0), | |
y[7], | |
(-y[6] / Math.pow(Math.pow(y[4], 2) + Math.pow(y[6], 2), 3.0 / 2.0)) - masaa * (y[6] - y[2]) / Math.pow((Math.pow(y[0] - y[4], 2) + Math.pow(y[2] - y[6], 2)), 3.0 / 2.0) | |
];*/ | |
//return [y[1], -y[0] / Math.pow(y[0] * y[0] + y[2] * y[2], 1.5) + (mu*alpha*y[1])/mass(t),y[3], -y[2] / Math.pow(y[0] * y[0] + y[2] * y[2], 1.5)+ (mu*alpha*y[3])/mass(t)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment