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

root/gliderproc/trunk/MATLAB/opnml/basics/ellipse_east.m

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

Initial import of Stark code.

Line 
1 function hell=ellipse_east(xc,yc,umaj,umin,orien,col)
2 %ELLIPSE_EAST plot ellipse given center, major/minor axes, orientation, etc.
3 % ELLIPSE_EAST plot ellipse given center, major and minor axes,
4 % orientation (CCW from EAST=0 radians, and color (optional, def = 'r')
5 %
6 %  Input : xc    - ellipse x-coordinate centers, usually node x's;
7 %          yc    - ellipse y-coordinate centers, usually node y's;
8 %          umaj  - major axis component
9 %          umin  - minor axis component
10 %          orien - orientation counterclockwise from east (radians)
11 %          col   - color to draw ellipses (optional, def = 'r')
12 %
13 %          ELLIPSE_EAST plots ellipses centered at (xc,yc) with major
14 %          and minor axes (umaj,umin) at an orientation
15 %          (orien) radians counterclockwise from east.  The first
16 %          five arguments are required; the color (col) is not and
17 %          defaults to red.
18 %
19 %  Output: ELLIPSE_EAST returns the handle to the ellipse object drawn.
20 %           
21 % Call as: hell=ellipse_east(xc,yc,umaj,umin,orien,col)
22 %
23 % Written by : Brian O. Blanton
24 %
25
26 % DEFINE ERROR STRINGS
27 err1=['Too many input arguments. Type "help ELLIPSE_EAST"'];
28
29 if nargin == 5
30    col='r';
31 elseif nargin>6
32    error(err1);
33 end
34 if length(xc)~=length(yc) | length(xc)~=length(umaj) | ...
35    length(umaj)~=length(umin) | length(umin)~=length(orien)
36    error('Length of xc,yc,umaj,umin,orien must be the same');
37 end
38
39 % compute non-rotated ellipses at (0,0)-origin
40 % force xc, yc, umaj, umin, orien  to be column vectors.
41 xc=xc(:);
42 yc=yc(:);
43 umaj=umaj(:);
44 umin=umin(:);
45 orien=orien(:);
46
47 % t must be a row vector
48 delt=pi/20;
49 t=0:delt:2*pi;
50 %t=-pi:delt:pi;
51 t=t(:)';
52
53 % compute non-rotated ellipses at (0,0)-origin
54 x=(umaj*ones(size(t)).*cos(ones(size(orien))*t))';
55 y=(umin*ones(size(t)).*sin(ones(size(orien))*t))';
56
57 % account for orientation
58 xn=x.*cos((orien*ones(size(t)))')-y.*sin((orien*ones(size(t)))');
59 yn=x.*sin((orien*ones(size(t)))')+y.*cos((orien*ones(size(t)))');
60 x=xn;
61 y=yn;
62 [nrow,ncol]=size(x);
63
64 % translate ellipses to input centers
65 xadd=(xc*ones(size(1:nrow)))';
66 yadd=(yc*ones(size(1:nrow)))';
67 x=x+xadd;
68 y=y+yadd;
69 x=[x;
70    NaN*ones(size(1:ncol))];
71 y=[y;
72    NaN*ones(size(1:ncol))];
73 x=x(:);
74 y=y(:);
75 hell=line(x,y,'Color',col);
76
77 % assign 'ellipse' string to 'UserData' parameter of hell
78 set(hell,'UserData','ellipse');
79 set(hell,'Tag','ellipse');
80
81 %
82 %LabSig  Brian O. Blanton
83 %        Department of Marine Sciences
84 %        12-7 Venable Hall
85 %        CB# 3300
86 %        University of North Carolina
87 %        Chapel Hill, NC
88 %                 27599-3300
89 %
90 %        brian_blanton@unc.edu
91 %
Note: See TracBrowser for help on using the browser.