Skip to content

Commit 909afcd

Browse files
feat: Implement 3D flight animation methods (animate_trajectory, animate_rotate) in Flight plots layer
Agent-Logs-Url: https://github.com/RocketPy-Team/RocketPy/sessions/90f7410c-65e8-4b6b-83be-0d2ecc7d8e0e Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
1 parent 7ea5f51 commit 909afcd

File tree

7 files changed

+574
-4
lines changed

7 files changed

+574
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Attention: The newest changes should be on top -->
3232

3333
### Added
3434

35-
-
35+
- ENH: Add 3D flight trajectory and attitude animations in Flight plots layer [#909](https://github.com/RocketPy-Team/RocketPy/pull/909)
3636

3737
### Changed
3838

docs/user/flight.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,51 @@ Flight Data Plots
454454
# Flight path and orientation
455455
flight.plots.flight_path_angle_data()
456456
457+
3D Flight Animation
458+
~~~~~~~~~~~~~~~~~~~
459+
460+
RocketPy can animate the simulated flight trajectory and attitude through the
461+
Flight plots layer.
462+
463+
.. note::
464+
465+
Install optional animation dependencies first:
466+
467+
.. code-block:: bash
468+
469+
pip install rocketpy[animation]
470+
471+
.. code-block:: python
472+
473+
# Fast start using RocketPy's built-in default STL model
474+
flight.plots.animate_trajectory(
475+
start=0.0,
476+
stop=min(flight.t_final, 20.0),
477+
time_step=0.05,
478+
)
479+
480+
# Or provide your own STL model file
481+
flight.plots.animate_trajectory(
482+
file_name="rocket.stl",
483+
start=0.0,
484+
stop=flight.t_final,
485+
time_step=0.05,
486+
azimuth=45,
487+
elevation=20,
488+
)
489+
490+
# Keep rocket centred and animate only attitude changes
491+
flight.plots.animate_rotate(
492+
file_name="rocket.stl",
493+
start=0.0,
494+
stop=min(flight.t_final, 20.0),
495+
time_step=0.05,
496+
)
497+
498+
Both methods validate the selected time interval and STL path before rendering.
499+
If ``vedo`` is not installed, RocketPy raises an informative ``ImportError``
500+
with installation instructions.
501+
457502
Forces and Moments
458503
~~~~~~~~~~~~~~~~~~
459504

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ build-backend = "setuptools.build_meta"
3434
[tool.setuptools]
3535
packages = { find = { where = ["."], include = ["rocketpy*"] } }
3636

37+
[tool.setuptools.package-data]
38+
"rocketpy.plots" = ["assets/*.stl"]
39+
3740

3841
[tool.setuptools.dynamic]
3942
dependencies = { file = ["requirements.txt"] }
@@ -61,14 +64,18 @@ env-analysis = [
6164
]
6265

6366
monte-carlo = [
64-
"imageio",
67+
"imageio",
6568
"multiprocess>=0.70",
6669
"statsmodels",
6770
"prettytable",
6871
"contextily>=1.0.0; python_version < '3.14'",
6972
]
7073

71-
all = ["rocketpy[env-analysis]", "rocketpy[monte-carlo]"]
74+
animation = [
75+
"vedo>=2024.5.1",
76+
]
77+
78+
all = ["rocketpy[env-analysis]", "rocketpy[monte-carlo]", "rocketpy[animation]"]
7279

7380

7481
[tool.coverage.report]

requirements-optional.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ timezonefinder
66
imageio
77
multiprocess>=0.70
88
statsmodels
9-
prettytable
9+
prettytable
10+
vedo>=2024.5.1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
solid default_rocket
2+
facet normal 0 0 1
3+
outer loop
4+
vertex 0 0 0
5+
vertex 1 0 0
6+
vertex 0 1 0
7+
endloop
8+
endfacet
9+
facet normal 0 0 -1
10+
outer loop
11+
vertex 0 0 0
12+
vertex 0 1 0
13+
vertex 1 0 0
14+
endloop
15+
endfacet
16+
endsolid default_rocket

0 commit comments

Comments
 (0)