def draw(self, axes): profile = self.getNacaString() x,y,cx,cy = naca.naca(profile, Airfoil.N_POINTS, False, True) xy = np.vstack((x,y)).transpose() while self._artists: a = self._artists.pop() if a in axes.get_children(): a.remove() color = "green" if naca.isCanonical(profile) \ else "orange" if naca.isReasonable(profile) \ else "red" # Foil solid: self._addArtist(axes, patches.Polygon(xy, color=color, alpha=0.50, zorder=4)) # Foil camber line: self._addArtist(axes, lines.Line2D(cx, cy, color=color, zorder=5)) mult = 5 if len(profile)==5 else 10 # Max camber position: loc = 0.01 * float(self._maxCamberLoc * mult) self._addArtist(axes, lines.Line2D((loc,loc), (-0.55,0.55), color='black', alpha=0.4, zorder=2)) self._addArtist(axes, lines.Line2D((0,loc), (-0.5,-0.5), color='black')) # Max camber amount: if( len(profile)==4 ): amt = 0.01 * self._maxCamberAmt y = si.interp1d(cx, cy)(loc) self._addArtist(axes, lines.Line2D((-0.15,1.15), (y,y), color='black', alpha=0.4, zorder=2)) self._addArtist(axes, lines.Line2D((-0.1,-0.1), (0,y), color='black')) if naca.isCanonical(profile): data = naca.nacaImage(profile) bbox = axes.bbox.extents x = bbox[2]-data.shape[1] y = bbox[3]-data.shape[0] imbox = boxes.AnnotationBbox(boxes.OffsetImage(data), (x,y), xycoords='axes pixels') imbox.set_zorder(10) # imbox.set_offset((x,y)) self._addArtist(axes, imbox)
def setNacaProfile(self, naca4str): self._profile = naca4str x,y,xc,yc = naca.naca(naca4str, 60) ctr = [np.average(x, weights=abs(y)), 0] x = ctr[0]-x self._points = (x,y)