Public
Edited
Dec 16, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
earthTrace
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
earthTrace = {
const earth = Object.assign({}, EARTH);

var t1 = getMillisecond();

const earthLst = [];

for (let i = 0; i < Math.pow(10, num); ++i) {
earth.t = t1;
t1 += 10;
updateM1(earth, SUN, t1);
earthLst.push(Object.assign({ i }, earth));
}

return earthLst;
}
Insert cell
updateM1 = (m1, m0, t1 = getMillisecond()) => {
const t = (t1 - m1.t) * 0.001,
r = {
// Vector
x: m0.x - m1.x,
y: m0.y - m1.y
},
d2 = r.x * r.x + r.y * r.y, // Distance ^ 2
d = Math.sqrt(d2); // Distance

const an = (system.factorG * m0.m) / d2,
a = {
// Accelerate
anorm: an,
ax: (an / d) * r.x,
ay: (an / d) * r.y
};

m1.vx += t * a.ax;
m1.vy += t * a.ay;
m1.v = Math.sqrt(m1.vx * m1.vx + m1.vy * m1.vy);

m1.x += t * m1.vx;
m1.y += t * m1.vy;
}
Insert cell
EARTH = {
const d = {
x: 100,
y: 0,
vx: speed * Math.cos((angle / 180) * Math.PI),
vy: speed * Math.sin((angle / 180) * Math.PI),
m: 1,
t: getMillisecond(),
name: "EARTH"
};
return d;
}
Insert cell
SUN = {
const d = {
x: 0,
y: 0,
vx: 0,
vy: 0,
m: mFactor,
t: getMillisecond(),
name: "SUN"
};
return d;
}
Insert cell
getMillisecond = () => {
return new Date() - 0;
}
Insert cell
system = {
const system = {
factorG: 1e2
};
return system;
}
Insert cell
height = 200
Insert cell

- EARTH: 5.965e24 kilograms
- SUN: 1.989e30 kilograms
- Distance: 1.5e11 meters
- Gfactor: 6.672e-11 m3 per kg s2
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more