NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/plots/drawperpvec.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 %
2 % DRAWPERPVEC draw vectors perpendicular to axis
3 %
4 % DRAWVEC drawvec(xo,yo,wx,wy,lcolor) is a routine to
5 %         draw perp vectors. This is a fairly low-level routine
6 %         in that in does no scaling to the vectors.  This function
7 %         is called primarily by PERPVECPLOT and returns the handle
8 %         of the vector object drawn.  Diameter of the object drawn
9 %         is the magnitude of the perpendicular vector.
10 %
11 % Inputs: xo,yo  - vector origins; arrow eminates from this point
12 %         wm     - vector magnitudes
13 %         lcolor - linecolor , 'r' = red, etc.
14 %
15 % Outputs: hc    - the handle to the ellipse drawn
16 %          hp    - the handle to the dot/x object drawn
17 %
18 % Call as:  [hc,hp]=drawperpvec(xo,yo,wx,wy,lcolor)
19 %
20 % Calls: plots/ell_east
21 %
22 % Catherine R. Edwards
23 % Last modified: 31 Jan 2004
24 %
25    function [hc,hp]=drawperpvec(xo,yo,wx,wy,lcolor)
26
27 % columnate the input vectors
28    xo=xo(:);
29    yo=yo(:);
30    wx=wx(:); wy=wy(:);
31
32 % get hold status of figure
33    holdstr=get(gca,'nextplot');
34    if(strcmp(holdstr,'replace'))
35      hold on;
36    end
37
38 % compute and draw circle - diameter of circle=wm
39    hc=ell_east(xo,yo,abs(wx)/2,abs(wy)/2,zeros(size(xo)),lcolor,300);
40    set(hc,'color',lcolor);
41    
42 % draw dot, lines from dot outward (if negative)
43    lt0=find(wx<0); ge0=find(wx>=0);
44    
45    hp(ge0)=plot(xo(ge0),yo(ge0),'.'); set(hp(ge0),'color',lcolor);
46    
47 %  get x/y points at angle equivalent to pi/2 on a circle
48
49    dx=(wx/2)*cos(pi/4); dy=(wy/2)*sin(pi/4);
50    x=[xo(lt0)-dx xo(lt0)+dx nan*xo(lt0) xo(lt0)-dx xo(lt0)+dx nan*xo(lt0)]';
51    y=[yo(lt0)-dy yo(lt0)+dy nan*xo(lt0) yo(lt0)+dy yo(lt0)-dy nan*xo(lt0)]';
52
53    x=x(:);
54    y=y(:);
55    hp(lt0)=line(x,y,'LineStyle','-','Color',lcolor);
56    set(hp,'color',lcolor);
57    
58    set(gca,'nextplot',holdstr);
Note: See TracBrowser for help on using the browser.