Published
Edited
Apr 21, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
connected = {
let n = orbit.nodes.length;

return orbit.states.map((s, i) => {
let theta1 = Math.atan2(s[n+1], s[1]);
let theta2 = Math.atan2(s[n+2], s[2]);

return {x: i, y1: theta1, y2: theta2};
});
}
Insert cell
Plot.plot({
height: 200,
x: {zero: true, label: 'radius'},
y: {
label: 'velocity',
grid: true,
zero: true,
},
marks: [
Plot.line(connected, {x: 'x', y: 'y1'}),
Plot.line(connected, {x: 'x', y: 'y2', stroke: 'blue'}),

Plot.dot([[connected[t].x, connected[t].y1]]),

//Plot.dot([velocityMags[t]]),
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
maxT = 600
Insert cell
Insert cell
// This is a slider w/ Play/Pause
import {Scrubber} from "@mbostock/scrubber"
Insert cell
Insert cell
{
let graph = createStandardGrid();

drawVector(graph, [[0, 0], [4, 4]], 'blue');

const theta = Math.atan2(4, 4);

const theta_p = theta + (Math.PI/2);

let r = 4;
let newX = r*Math.cos(theta_p);
let newY = r*Math.sin(theta_p);

drawVector(graph, [[0, 0], [newX, newY]], 'green');

return graph.svg.node();
}
Insert cell
viewof ratio1 = Inputs.range([0.25, 10], {label: "radius ratio", value: 2, step: 0.01})
Insert cell
ratio_fn = (x) => 360*(Math.PI*(Math.pow((0.5 + (1/(2*x))), 1.5) - 1))/(2*Math.PI);
Insert cell
ratio_fn(ratio1)
Insert cell
Math.pow(0.75, 1.5)
Insert cell
{
let graph = createStandardGrid([-2, 10],
//[-Math.PI, 2*Math.PI]
[-180, 360]
);

let fn = (x) => 360*(Math.PI*(Math.pow((0.5 + (1/(2*x))), 1.5) - 1))/(2*Math.PI);

let pts = [];

for (let i = 0.1; i <= 20; i += 0.1) {
pts.push([i, fn(i)]);
}

graph.svg.append("path")
.attr("d", d3.line()(pts.map(p => [graph.x(p[0]), graph.y(p[1])])))
.attr('stroke', 'blue')
.attr('fill', 'none');

graph.svg.append("circle")
.attr('r', 3)
.attr('cx', graph.x(ratio1))
.attr('cy', graph.y(fn(ratio1)))
.attr('fill', 'blue');

graph.svg.append("text")
.attr('r', 3)
.attr('x', graph.x(ratio1))
.attr('y', graph.y(fn(ratio1)))
.attr('dx', 5)
.attr('dy', -5)
.attr('font-size', 10)
.attr('fill', 'blue')
.text(fn(ratio1).toLocaleString());
//return pts;
return graph.svg.node();
}
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