Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions examples/browser/rocket_trajectory_optimization.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ <h1>Rocket trajectory optimization</h1>
label: resultName.slice(7),
data: sim.evaluate(
'concat('
+ `(${resultName}[:,4] - phi0) * r0 / rad / km,` // Surface distance from start (in km)
+ `(${resultName}[:,1] - r0) / km` // Height above surface (in km)
+ `(${resultName}[:,[4]] - phi0) * r0 / rad / km,` // Surface distance from start (in km)
+ `(${resultName}[:,[1]] - r0) / km` // Height above surface (in km)
+ ')'
).toArray().map(([x, y]) => ({ x, y })),
borderColor: i % 2 ? '#999' : '#dc3912',
Expand All @@ -173,7 +173,7 @@ <h1>Rocket trajectory optimization</h1>
}])
createChart([{
label: 'height (in km)',
data: sim.evaluate("concat((result[:, 1] - r0), result[:, 6])")
data: sim.evaluate("concat((result[:, [1]] - r0), result[:, [6]])")
.toArray()
.map(([r, t]) => ({ x: t.toNumber('s'), y: r.toNumber('km') })),
}])
Expand All @@ -185,7 +185,7 @@ <h1>Rocket trajectory optimization</h1>
}])
createChart([{
label: 'acceleration (in m/s^2)',
data: sim.evaluate("concat(diff(result[:, 2]) ./ diff(result[:, 6]), result[:end-1, 6])")
data: sim.evaluate("concat(diff(result[:, [2]]) ./ diff(result[:, [6]]), result[:end-1, [6]])")
.toArray()
.map(([acc, t]) => ({ x: t.toNumber('s'), y: acc.toNumber('m/s^2') })),
}])
Expand All @@ -209,6 +209,7 @@ <h1>Rocket trajectory optimization</h1>
{
data: sim.evaluate("map(0:0.25:360, function(angle) = rotate([r0/km, 0], angle))")
.toArray()
.map(row => row.toArray())
.map(([x, y]) => ({ x, y })),
borderColor: "#999",
fill: true
Expand Down
Loading