@@ -966,14 +966,30 @@ def add_motor(self, motor, position): # pylint: disable=too-many-statements
966
966
self .evaluate_com_to_cdm_function ()
967
967
self .evaluate_nozzle_gyration_tensor ()
968
968
969
+ def __add_single_surface (self , surface , position ):
970
+ """Adds a single aerodynamic surface to the rocket. Makes checks for
971
+ rail buttons case, and position type.
972
+ """
973
+ position = (
974
+ Vector ([0 , 0 , position ])
975
+ if not isinstance (position , (Vector , tuple , list ))
976
+ else Vector (position )
977
+ )
978
+ if isinstance (surface , RailButtons ):
979
+ self .rail_buttons = Components ()
980
+ self .rail_buttons .add (surface , position )
981
+ else :
982
+ self .aerodynamic_surfaces .add (surface , position )
983
+ self .__evaluate_single_surface_cp_to_cdm (surface , position )
984
+
969
985
def add_surfaces (self , surfaces , positions ):
970
986
"""Adds one or more aerodynamic surfaces to the rocket. The aerodynamic
971
987
surface must be an instance of a class that inherits from the
972
988
AeroSurface (e.g. NoseCone, TrapezoidalFins, etc.)
973
989
974
990
Parameters
975
991
----------
976
- surfaces : list, AeroSurface, NoseCone, TrapezoidalFins, EllipticalFins, Tail
992
+ surfaces : list, AeroSurface, NoseCone, TrapezoidalFins, EllipticalFins, Tail, RailButtons
977
993
Aerodynamic surface to be added to the rocket. Can be a list of
978
994
AeroSurface if more than one surface is to be added.
979
995
positions : int, float, list, tuple, Vector
@@ -996,22 +1012,11 @@ def add_surfaces(self, surfaces, positions):
996
1012
-------
997
1013
None
998
1014
"""
999
- # TODO: separate this method into smaller methods: https://github.com/RocketPy-Team/RocketPy/pull/696#discussion_r1771978422
1000
1015
try :
1001
1016
for surface , position in zip (surfaces , positions ):
1002
- if not isinstance (position , (Vector , tuple , list )):
1003
- position = Vector ([0 , 0 , position ])
1004
- else :
1005
- position = Vector (position )
1006
- self .aerodynamic_surfaces .add (surface , position )
1007
- self .__evaluate_single_surface_cp_to_cdm (surface , position )
1017
+ self .__add_single_surface (surface , position )
1008
1018
except TypeError :
1009
- if not isinstance (positions , (Vector , tuple , list )):
1010
- positions = Vector ([0 , 0 , positions ])
1011
- else :
1012
- positions = Vector (positions )
1013
- self .aerodynamic_surfaces .add (surfaces , positions )
1014
- self .__evaluate_single_surface_cp_to_cdm (surfaces , positions )
1019
+ self .__add_single_surface (surfaces , positions )
1015
1020
1016
1021
self .evaluate_center_of_pressure ()
1017
1022
self .evaluate_stability_margin ()
0 commit comments