Skip to content

Commit

Permalink
Merge pull request #516 from RocketPy-Team/bug/empty-motor-draw
Browse files Browse the repository at this point in the history
BUG: EmptyMotor is breaking  the Rocket.draw() method
  • Loading branch information
Gui-FernandesBR authored Dec 19, 2023
2 parents 6347371 + f1367e3 commit 476872f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ straightforward as possible.
### Fixed

- ENH: Parachute trigger doesn't work if "Apogee" is used instead of "apogee" [#489](https://github.com/RocketPy-Team/RocketPy/pull/489)
- FIX: EmptyMotor is breaking the Rocket.draw() method [#516](https://github.com/RocketPy-Team/RocketPy/pull/516)

## [v1.1.4] - 2023-12-07

Expand Down
26 changes: 13 additions & 13 deletions rocketpy/plots/rocket_plots.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np

from rocketpy.motors import HybridMotor, LiquidMotor, SolidMotor
from rocketpy.motors import EmptyMotor, HybridMotor, LiquidMotor, SolidMotor
from rocketpy.rocket.aero_surface import Fins, NoseCone, Tail


Expand Down Expand Up @@ -332,10 +332,6 @@ def draw(self, vis_args=None):
self.rocket.motor_position + self.rocket.motor.nozzle_position * total_csys
)

nozzle = self.rocket.motor.plots._generate_nozzle(
translate=(nozzle_position, 0), csys=self.rocket._csys
)

# List of motor patches
motor_patches = []

Expand Down Expand Up @@ -414,14 +410,18 @@ def draw(self, vis_args=None):
motor_patches += [tank]

# add nozzle last so it is in front of the other patches
motor_patches += [nozzle]
outline = self.rocket.motor.plots._generate_motor_region(
list_of_patches=motor_patches
)
# add outline first so it is behind the other patches
ax.add_patch(outline)
for patch in motor_patches:
ax.add_patch(patch)
if not isinstance(self.rocket.motor, EmptyMotor):
nozzle = self.rocket.motor.plots._generate_nozzle(
translate=(nozzle_position, 0), csys=self.rocket._csys
)
motor_patches += [nozzle]
outline = self.rocket.motor.plots._generate_motor_region(
list_of_patches=motor_patches
)
# add outline first so it is behind the other patches
ax.add_patch(outline)
for patch in motor_patches:
ax.add_patch(patch)

# Check if nozzle is beyond the last surface, if so draw a tube
# to it, with the radius of the last surface
Expand Down

0 comments on commit 476872f

Please sign in to comment.