Skip to content

Commit

Permalink
reimplement wing visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
helo9 committed Jul 28, 2019
1 parent 2020418 commit 1a0aebf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_data_wing.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ def test_serialization(d43wing):
# control surfaces are optional, should not raise any Exception if missing
del data['controlsurfaces']
Wing.deserialize(data)


def test_plot(d43wing):
d43wing.plot()
33 changes: 33 additions & 0 deletions wingstructure/data/wing.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,39 @@ def deserialize(cls, adict):

return wing

def plot(self):
import matplotlib.pyplot as plt

# draw centerline
plt.axvline(x=0, linestyle='-.')

# draw sections
x_positions = []
y_positions = []
chord_lengths = []

for section in self.sections:
x = section.pos.x+self.x
y = section.pos.y
chord = section.chord

plt.plot((y, y), (-x, -x-chord), 'r')
x_positions.append(x)
y_positions.append(y)
chord_lengths.append(chord)

y_positions = np.array(y_positions)

# draw leading edge
plt.plot(y_positions, -1*np.array(x_positions), 'b' )
# draw trailing edge
plt.plot(y_positions, -1*np.array(x_positions)-np.array(chord_lengths), 'b')

# format
plt.axis('equal')
plt.axis('off')
plt.xlim(-1, max(y_positions)+1)


class FlatWing(Wing):
"""A class representing the flattend version of a wing
Expand Down

0 comments on commit 1a0aebf

Please sign in to comment.