|
89 | 89 | %-------------------------------------------------------------------------%
|
90 | 90 |
|
91 | 91 | %-quiver barbs-%
|
92 |
| -maxheadsize = quiver_data.MaxHeadSize; % 'MaxHeadSize' scalar, matlab clips to 0.2 |
93 |
| -head_width = deg2rad(17); % barb width, not supported by matlab |
94 |
| -for n = 1:length(xdata) % xdata and ydata had better be the same length... throw an exception if this isn't true? |
| 92 | +% 'MaxHeadSize' scalar, matlab clips to 0.2 in r2014b |
| 93 | +maxheadsize = quiver_data.MaxHeadSize; |
| 94 | +% barb angular width, not supported by matlab |
| 95 | +head_width = deg2rad(17.5); |
| 96 | +for n = 1:length(xdata) |
95 | 97 | % length of arrow
|
96 | 98 | l = norm([0.1*udata(n), 0.1*vdata(n)]);
|
97 | 99 |
|
98 | 100 | % angle of arrow
|
99 | 101 | phi = atan2(vdata(n),udata(n));
|
100 | 102 |
|
101 |
| - % make barb with specified angular width and length prop. to arrow |
| 103 | + % make barb with specified angular width, length is prop. to arrow |
102 | 104 | barb = [...
|
103 | 105 | [-maxheadsize*l*cos(head_width), maxheadsize*l*sin(head_width)]; ...
|
104 | 106 | [0, 0]; ...
|
105 |
| - [-maxheadsize*l*cos(head_width), -maxheadsize*l*sin(head_width)]; |
| 107 | + [-maxheadsize*l*cos(head_width), -maxheadsize*l*sin(head_width)]; ... |
| 108 | + [nan, nan]; ... |
106 | 109 | ]';
|
107 | 110 |
|
108 | 111 | % affine matrix: rotate by arrow angle and translate to end of arrow
|
|
112 | 115 | [xdata(n) + 0.1*udata(n), ydata(n) + 0.1*vdata(n), 1];
|
113 | 116 | ]);
|
114 | 117 |
|
115 |
| - % apply transformation to barb |
| 118 | + % place barb at end of arrow |
116 | 119 | barb = transformPointsForward(barb_transformation, barb')';
|
117 | 120 |
|
118 |
| - % add barb to plot data |
119 |
| - obj.data{quiverIndex}.x(end+1) = barb(1,1); % point 1 |
120 |
| - obj.data{quiverIndex}.y(end+1) = barb(2,1); |
121 |
| - obj.data{quiverIndex}.x(end+1) = barb(1,2); % point 2 |
122 |
| - obj.data{quiverIndex}.y(end+1) = barb(2,2); |
123 |
| - obj.data{quiverIndex}.x(end+1) = barb(1,3); % point 3 |
124 |
| - obj.data{quiverIndex}.y(end+1) = barb(2,3); |
125 |
| - obj.data{quiverIndex}.x(end+1) = nan; % insert blank line between successive barbs |
126 |
| - obj.data{quiverIndex}.y(end+1) = nan; |
| 121 | + % add barb to plot data, inserting is optimized in matlab >2010 |
| 122 | + for col = 1:4 |
| 123 | + obj.data{quiverIndex}.x(end+1) = barb(1,col); % point 1 |
| 124 | + obj.data{quiverIndex}.y(end+1) = barb(2,col); |
| 125 | + end |
127 | 126 | end
|
128 | 127 |
|
129 | 128 | %-------------------------------------------------------------------------%
|
|
0 commit comments