Skip to content

Commit 3b54267

Browse files
authored
docs: fix the rocket trajectory optimization example (#3654)
1 parent fee4561 commit 3b54267

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

examples/browser/rocket_trajectory_optimization.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ <h1>Rocket trajectory optimization</h1>
151151
label: resultName.slice(7),
152152
data: sim.evaluate(
153153
'concat('
154-
+ `(${resultName}[:,4] - phi0) * r0 / rad / km,` // Surface distance from start (in km)
155-
+ `(${resultName}[:,1] - r0) / km` // Height above surface (in km)
154+
+ `(${resultName}[:,[4]] - phi0) * r0 / rad / km,` // Surface distance from start (in km)
155+
+ `(${resultName}[:,[1]] - r0) / km` // Height above surface (in km)
156156
+ ')'
157157
).toArray().map(([x, y]) => ({ x, y })),
158158
borderColor: i % 2 ? '#999' : '#dc3912',
@@ -173,7 +173,7 @@ <h1>Rocket trajectory optimization</h1>
173173
}])
174174
createChart([{
175175
label: 'height (in km)',
176-
data: sim.evaluate("concat((result[:, 1] - r0), result[:, 6])")
176+
data: sim.evaluate("concat((result[:, [1]] - r0), result[:, [6]])")
177177
.toArray()
178178
.map(([r, t]) => ({ x: t.toNumber('s'), y: r.toNumber('km') })),
179179
}])
@@ -185,7 +185,7 @@ <h1>Rocket trajectory optimization</h1>
185185
}])
186186
createChart([{
187187
label: 'acceleration (in m/s^2)',
188-
data: sim.evaluate("concat(diff(result[:, 2]) ./ diff(result[:, 6]), result[:end-1, 6])")
188+
data: sim.evaluate("concat(diff(result[:, [2]]) ./ diff(result[:, [6]]), result[:end-1, [6]])")
189189
.toArray()
190190
.map(([acc, t]) => ({ x: t.toNumber('s'), y: acc.toNumber('m/s^2') })),
191191
}])
@@ -209,6 +209,7 @@ <h1>Rocket trajectory optimization</h1>
209209
{
210210
data: sim.evaluate("map(0:0.25:360, function(angle) = rotate([r0/km, 0], angle))")
211211
.toArray()
212+
.map(row => row.toArray())
212213
.map(([x, y]) => ({ x, y })),
213214
borderColor: "#999",
214215
fill: true

0 commit comments

Comments
 (0)