@@ -4176,7 +4176,10 @@ def export_kml(
41764176 color = color ,
41774177 altitude_mode = altitude_mode ,
41784178 )
4179- def animate_trajectory (self , file_name , start = 0 , stop = None , time_step = 0.1 , ** kwargs ):
4179+
4180+ def animate_trajectory (
4181+ self , file_name , start = 0 , stop = None , time_step = 0.1 , ** kwargs
4182+ ):
41804183 """
41814184 6-DOF Animation of the flight trajectory using Vedo.
41824185
@@ -4208,7 +4211,7 @@ def animate_trajectory(self, file_name, start=0, stop=None, time_step=0.1, **kwa
42084211 ------
42094212 ImportError
42104213 If the 'vedo' package is not installed.
4211-
4214+
42124215 Notes
42134216 -----
42144217 This feature requires the 'vedo' package. Install it with:
@@ -4250,8 +4253,10 @@ def animate_trajectory(self, file_name, start=0, stop=None, time_step=0.1, **kwa
42504253 rocket = Mesh (file_name ).c ("green" )
42514254 rocket .pos (self .x (start ), self .y (start ), 0 ).add_trail (n = len (self .x [:, 1 ]))
42524255 # Create trail
4253- trail_points = [[self .x (t ), self .y (t ), self .z (t ) - self .env .elevation ]
4254- for t in np .arange (start , stop , time_step )]
4256+ trail_points = [
4257+ [self .x (t ), self .y (t ), self .z (t ) - self .env .elevation ]
4258+ for t in np .arange (start , stop , time_step )
4259+ ]
42554260 trail = Line (trail_points , c = "k" , alpha = 0.5 )
42564261 # Setup Plotter
42574262 plt = Plotter (axes = 1 , interactive = False )
@@ -4260,21 +4265,21 @@ def animate_trajectory(self, file_name, start=0, stop=None, time_step=0.1, **kwa
42604265 # Animation Loop
42614266 for t in np .arange (start , stop , time_step ):
42624267 # Calculate rotation angle and vector from quaternions
4263- # Note: This simple rotation logic mimics the old branch.
4264- # Ideally, vedo handles orientation via matrix, but we stick
4268+ # Note: This simple rotation logic mimics the old branch.
4269+ # Ideally, vedo handles orientation via matrix, but we stick
42654270 # to the provided logic for now.
4266-
4271+
42674272 # e0 is the scalar part of the quaternion
4268- angle = np .arccos (2 * self .e0 (t )** 2 - 1 )
4273+ angle = np .arccos (2 * self .e0 (t ) ** 2 - 1 )
42694274 k = np .sin (angle / 2 ) if np .sin (angle / 2 ) != 0 else 1
4270-
4275+
42714276 # Update position and rotation
42724277 # Adjusting for ground elevation
42734278 rocket .pos (self .x (t ), self .y (t ), self .z (t ) - self .env .elevation )
42744279 rocket .rotate_x (self .e1 (t ) / k )
42754280 rocket .rotate_y (self .e2 (t ) / k )
42764281 rocket .rotate_z (self .e3 (t ) / k )
4277-
4282+
42784283 # update the scene
42794284 plt .show (world , rocket , trail )
42804285
@@ -4283,7 +4288,7 @@ def animate_trajectory(self, file_name, start=0, stop=None, time_step=0.1, **kwa
42834288 while time .time () - start_pause < time_step :
42844289 plt .render ()
42854290
4286- if getattr (plt , ' escaped' , False ):
4291+ if getattr (plt , " escaped" , False ):
42874292 break
42884293
42894294 plt .interactive ().close ()
@@ -4311,7 +4316,7 @@ def animate_rotate(self, file_name, start=0, stop=None, time_step=0.1, **kwargs)
43114316 - elevation (float): Rotation in degrees above the horizon.
43124317 - roll (float): Rotation in degrees around the view axis.
43134318 - zoom (float): Zoom level (default 1).
4314-
4319+
43154320 Returns
43164321 -------
43174322 None
@@ -4329,13 +4334,13 @@ def animate_rotate(self, file_name, start=0, stop=None, time_step=0.1, **kwargs)
43294334 "Install it with:\n "
43304335 " pip install rocketpy[animation]\n "
43314336 ) from e
4332-
4337+
43334338 # Enable interaction if needed
43344339 try :
43354340 settings .allow_interaction = True
43364341 except AttributeError :
43374342 pass # Not available in newer versions of vedo
4338-
4343+
43394344 if stop is None :
43404345 stop = self .t_final
43414346
@@ -4355,9 +4360,9 @@ def animate_rotate(self, file_name, start=0, stop=None, time_step=0.1, **kwargs)
43554360 plt .show (world , rocket , __doc__ , viewup = "z" , ** kwargs )
43564361
43574362 for t in np .arange (start , stop , time_step ):
4358- angle = np .arccos (2 * self .e0 (t )** 2 - 1 )
4363+ angle = np .arccos (2 * self .e0 (t ) ** 2 - 1 )
43594364 k = np .sin (angle / 2 ) if np .sin (angle / 2 ) != 0 else 1
4360-
4365+
43614366 # Keep position static (relative start) to observe only rotation
43624367 rocket .pos (self .x (start ), self .y (start ), 0 )
43634368 rocket .rotate_x (self .e1 (t ) / k )
@@ -4366,12 +4371,12 @@ def animate_rotate(self, file_name, start=0, stop=None, time_step=0.1, **kwargs)
43664371
43674372 plt .show (world , rocket )
43684373
4369- if getattr (plt , ' escaped' , False ):
4374+ if getattr (plt , " escaped" , False ):
43704375 break
43714376
43724377 plt .interactive ().close ()
43734378 return None
4374-
4379+
43754380 def info (self ):
43764381 """Prints out a summary of the data available about the Flight."""
43774382 self .prints .all ()
0 commit comments