def setPos(self,pos): """ Changes position for thinning crane, and records monitors associated with this. """ #record angles: cyl = getCylindrical(pos, origin=self.m.pos, direction=self.m.direction) oldCyl = getCylindrical(self.pos, origin=self.m.pos, direction=self.m.direction) dTh=abs(oldCyl[1]-cyl[1]) dr=abs(oldCyl[0]-cyl[0]) traveltime=max(dTh/self.m.velocities['crane angular'], dr/self.m.velocities['crane radial']) self.pos=pos return traveltime+self.m.times['crane const']
def _fixNodes(self, endPoints, w): """get nodes from endpoints. depending on the order in endpoints, the nodes are ordered different, but always correct""" #r=np.array(endPoints[0])-np.array(endPoints[1]) [p2,p1]=endPoints #xhat=np.array((1,0)) #norm ==1 r, th=fn.getCylindrical(p1,origin=p2) if not self.direction: self.direction=th cart=fn.getCartesian dx=w*0.5 nodes=[cart([dx, 0],origin=p2, direction=th,fromLocalCart=True)] nodes.append(cart([-dx, 0],origin=p2, direction=th,fromLocalCart=True)) nodes.append(cart([-dx, r],origin=p2, direction=th,fromLocalCart=True)) nodes.append(cart([dx, r],origin=p2, direction=th,fromLocalCart=True)) return nodes
def plot_coverage(G=None, ax=None, color='#666677'): """ plots coverage from the road. Shows overlaps and spots missed. """ if not G or not ax: raise Exception('need ax and G to plot coverage') points=15 angles=np.linspace(0, np.pi, points) #for half circle for e in G.edges(data=False): p1=np.array(e[0]) p2=np.array(e[1]) d=p1-p2 x=e[0][0], e[1][0] y=e[0][1], e[1][1] w=G.C*2 nodes=[] r,dir=fun.getCylindrical(e[1], origin=e[0]) l=fun.getDistance(e[0], e[1]) nodes.append(fun.getCartesian([w/2.,0], origin=e[0], direction=dir, fromLocalCart=True)) nodes.append(fun.getCartesian([w/2.,l], origin=e[0], direction=dir, fromLocalCart=True)) #now, fix end half circle. for ang in angles: loc=fun.getCartesian([w/2., ang]) #get local cartesian from cyl. p=fun.getCartesian(loc, origin=e[1], direction=dir, fromLocalCart=True) nodes.append(p) nodes.append(fun.getCartesian([-w/2.,l], origin=e[0], direction=dir, fromLocalCart=True)) nodes.append(fun.getCartesian([-w/2.,0], origin=e[0], direction=dir, fromLocalCart=True)) #fix the other half circle for ang in angles: loc=fun.getCartesian([w/2., ang]) #get local cartesian from cyl. p=fun.getCartesian(loc, origin=e[0], direction=dir-np.pi, fromLocalCart=True) nodes.append(p) pol = Polygon(nodes, alpha=150, color=color, edgecolor='none') ax.add_patch(pol) return ax
def setPos(self, pos): #determine direction.. from current pos to next pos. If going backwards, use the default.. if pos==self.road.startPoint or pos==self.m.getTreeDumpSpot(self.side): #going back.. [r, self.direction]=self.m.getCylindrical(pos) else: [r,self.direction]=getCylindrical(pos,origin=self.pos, direction=pi/2.) return super(BCHead, self).setPos(pos)