@@ -187,7 +187,7 @@ def get_drawing_geometry(self) -> RocketDrawingGeometry:
187187 for surface , position in rocket .aerodynamic_surfaces :
188188 position_z = position .z
189189 if isinstance (surface , RocketPyNoseCone ):
190- x_vals = ( - csys * np .asarray (surface .shape_vec [0 ]) + position_z )
190+ x_vals = - csys * np .asarray (surface .shape_vec [0 ]) + position_z
191191 y_vals = np .asarray (surface .shape_vec [1 ])
192192 nose_cones .append (
193193 NoseConeGeometry (
@@ -199,10 +199,15 @@ def get_drawing_geometry(self) -> RocketDrawingGeometry:
199199 )
200200 )
201201 drawn_surfaces .append (
202- (surface , float (x_vals [- 1 ]), float (surface .rocket_radius ), float (x_vals [- 1 ]))
202+ (
203+ surface ,
204+ float (x_vals [- 1 ]),
205+ float (surface .rocket_radius ),
206+ float (x_vals [- 1 ]),
207+ )
203208 )
204209 elif isinstance (surface , RocketPyTail ):
205- x_vals = ( - csys * np .asarray (surface .shape_vec [0 ]) + position_z )
210+ x_vals = - csys * np .asarray (surface .shape_vec [0 ]) + position_z
206211 y_vals = np .asarray (surface .shape_vec [1 ])
207212 tails .append (
208213 TailGeometry (
@@ -223,14 +228,14 @@ def get_drawing_geometry(self) -> RocketDrawingGeometry:
223228 elif isinstance (surface , RocketPyFins ):
224229 num_fins = surface .n
225230 x_fin = - csys * np .asarray (surface .shape_vec [0 ]) + position_z
226- y_fin = np .asarray (surface .shape_vec [1 ]) + surface .rocket_radius
231+ y_fin = (
232+ np .asarray (surface .shape_vec [1 ]) + surface .rocket_radius
233+ )
227234 outlines : list [FinOutline ] = []
228235 last_x_rotated = float (x_fin [- 1 ])
229236 for i in range (num_fins ):
230237 angle = 2 * np .pi * i / num_fins
231- rotation_matrix = np .array (
232- [[1 , 0 ], [0 , np .cos (angle )]]
233- )
238+ rotation_matrix = np .array ([[1 , 0 ], [0 , np .cos (angle )]])
234239 rotated = rotation_matrix @ np .vstack ((x_fin , y_fin ))
235240 outlines .append (
236241 FinOutline (
@@ -242,16 +247,20 @@ def get_drawing_geometry(self) -> RocketDrawingGeometry:
242247 kind = (
243248 "trapezoidal"
244249 if isinstance (surface , RocketPyTrapezoidalFins )
245- else "elliptical"
246- if isinstance (surface , RocketPyEllipticalFins )
247- else "free_form"
250+ else (
251+ "elliptical"
252+ if isinstance (surface , RocketPyEllipticalFins )
253+ else "free_form"
254+ )
248255 )
249256 fins .append (
250257 FinsGeometry (
251258 name = getattr (surface , "name" , None ),
252259 kind = kind ,
253260 n = int (num_fins ),
254- cant_angle_deg = float (getattr (surface , "cant_angle" , 0.0 ) or 0.0 ),
261+ cant_angle_deg = float (
262+ getattr (surface , "cant_angle" , 0.0 ) or 0.0
263+ ),
255264 position = float (position_z ),
256265 outlines = outlines ,
257266 )
@@ -278,13 +287,17 @@ def get_drawing_geometry(self) -> RocketDrawingGeometry:
278287
279288 tubes = self ._build_tubes (drawn_surfaces )
280289 motor_geometry , nozzle_position = self ._build_motor_geometry (csys )
281- tubes += self ._build_nozzle_tube (tubes , drawn_surfaces , nozzle_position , csys )
290+ tubes += self ._build_nozzle_tube (
291+ tubes , drawn_surfaces , nozzle_position , csys
292+ )
282293 rail_buttons = self ._build_rail_buttons (csys )
283294 sensors = self ._build_sensors ()
284295
285296 try :
286297 center_of_mass = float (rocket .center_of_mass (0 ))
287- except Exception : # pragma: no cover - defensive; rocket may not be fully built
298+ except (
299+ Exception
300+ ): # pragma: no cover - defensive; rocket may not be fully built
288301 center_of_mass = None
289302 try :
290303 cp_position = float (rocket .cp_position (0 ))
@@ -298,7 +311,9 @@ def get_drawing_geometry(self) -> RocketDrawingGeometry:
298311 return RocketDrawingGeometry (
299312 radius = float (rocket .radius ),
300313 csys = int (csys ),
301- coordinate_system_orientation = str (rocket .coordinate_system_orientation ),
314+ coordinate_system_orientation = str (
315+ rocket .coordinate_system_orientation
316+ ),
302317 nose_cones = nose_cones ,
303318 tails = tails ,
304319 fins = fins ,
@@ -365,15 +380,11 @@ def _build_motor_geometry(
365380 chamber = motor .plots ._generate_combustion_chamber (
366381 translate = (grains_cm_position , 0 ), label = None
367382 )
368- patches .append (
369- MotorPatch (role = "chamber" , ** _polygon_xy (chamber ))
370- )
383+ patches .append (MotorPatch (role = "chamber" , ** _polygon_xy (chamber )))
371384 for grain in motor .plots ._generate_grains (
372385 translate = (grains_cm_position , 0 )
373386 ):
374- patches .append (
375- MotorPatch (role = "grain" , ** _polygon_xy (grain ))
376- )
387+ patches .append (MotorPatch (role = "grain" , ** _polygon_xy (grain )))
377388 elif isinstance (motor , HybridMotor ):
378389 motor_type = "hybrid"
379390 grains_cm_position = (
@@ -383,29 +394,21 @@ def _build_motor_geometry(
383394 chamber = motor .plots ._generate_combustion_chamber (
384395 translate = (grains_cm_position , 0 ), label = None
385396 )
386- patches .append (
387- MotorPatch (role = "chamber" , ** _polygon_xy (chamber ))
388- )
397+ patches .append (MotorPatch (role = "chamber" , ** _polygon_xy (chamber )))
389398 for grain in motor .plots ._generate_grains (
390399 translate = (grains_cm_position , 0 )
391400 ):
392- patches .append (
393- MotorPatch (role = "grain" , ** _polygon_xy (grain ))
394- )
401+ patches .append (MotorPatch (role = "grain" , ** _polygon_xy (grain )))
395402 for tank , _center in motor .plots ._generate_positioned_tanks (
396403 translate = (rocket .motor_position , 0 ), csys = total_csys
397404 ):
398- patches .append (
399- MotorPatch (role = "tank" , ** _polygon_xy (tank ))
400- )
405+ patches .append (MotorPatch (role = "tank" , ** _polygon_xy (tank )))
401406 elif isinstance (motor , LiquidMotor ):
402407 motor_type = "liquid"
403408 for tank , _center in motor .plots ._generate_positioned_tanks (
404409 translate = (rocket .motor_position , 0 ), csys = total_csys
405410 ):
406- patches .append (
407- MotorPatch (role = "tank" , ** _polygon_xy (tank ))
408- )
411+ patches .append (MotorPatch (role = "tank" , ** _polygon_xy (tank )))
409412 elif isinstance (motor , GenericMotor ):
410413 # RocketPy's rocket.draw() does not render a chamber for GenericMotor —
411414 # _MotorPlots._generate_combustion_chamber depends on grain fields that
@@ -414,8 +417,7 @@ def _build_motor_geometry(
414417 # chamber_position) so users can see their chamber geometry in the playground.
415418 motor_type = "generic"
416419 chamber_center_x = (
417- rocket .motor_position
418- + motor .chamber_position * total_csys
420+ rocket .motor_position + motor .chamber_position * total_csys
419421 )
420422 chamber_patch = _build_generic_chamber_patch (
421423 center_x = chamber_center_x ,
@@ -438,19 +440,15 @@ def _build_motor_geometry(
438440 # so we need matplotlib Polygon objects; rebuild them once from our
439441 # coordinate copies.
440442 try :
441- mpl_patches = [
442- _rebuild_polygon (p .x , p .y ) for p in patches
443- ]
443+ mpl_patches = [_rebuild_polygon (p .x , p .y ) for p in patches ]
444444 outline_patch = motor .plots ._generate_motor_region (
445445 list_of_patches = mpl_patches
446446 )
447447 patches .insert (
448448 0 , MotorPatch (role = "outline" , ** _polygon_xy (outline_patch ))
449449 )
450450 except Exception as exc : # pragma: no cover - defensive
451- logger .warning (
452- "Failed to generate motor outline patch: %s" , exc
453- )
451+ logger .warning ("Failed to generate motor outline patch: %s" , exc )
454452
455453 return (
456454 MotorDrawingGeometry (
@@ -635,7 +633,7 @@ def get_rocketpy_finset(fins: Fins, kind: str) -> RocketPyFins:
635633 for key , value in fins .get_additional_parameters ().items ()
636634 if key not in base_kwargs
637635 }
638-
636+
639637 match kind :
640638 case "trapezoidal" :
641639 factory = RocketPyTrapezoidalFins
@@ -732,7 +730,9 @@ def _build_generic_chamber_patch(
732730 chamber_radius : float
733731 Internal radius of the chamber (m).
734732 """
735- from matplotlib .patches import Polygon # local import keeps service cold-start lean
733+ from matplotlib .patches import (
734+ Polygon ,
735+ ) # local import keeps service cold-start lean
736736
737737 half_len = chamber_height / 2.0
738738 # Top edge then mirror to the bottom, matching _generate_combustion_chamber's
@@ -774,5 +774,8 @@ def _rebuild_polygon(x: list[float], y: list[float]):
774774 Used only so _MotorPlots._generate_motor_region can read patch.xy
775775 bounds when we assemble the motor outline.
776776 """
777- from matplotlib .patches import Polygon # local import keeps service cold-start lean
777+ from matplotlib .patches import (
778+ Polygon ,
779+ ) # local import keeps service cold-start lean
780+
778781 return Polygon (np .column_stack ([np .asarray (x ), np .asarray (y )]))
0 commit comments