|
88 | 88 |
|
89 | 89 | %-------------------------------------------------------------------------%
|
90 | 90 |
|
| 91 | +%-quiver barbs-% |
| 92 | +if isHG2() |
| 93 | + % 'MaxHeadSize' scalar, matlab clips to 0.2 in r2014b |
| 94 | + maxheadsize = quiver_data.MaxHeadSize; |
| 95 | + % barb angular width, not supported by matlab |
| 96 | + head_width = deg2rad(17.5); |
| 97 | + for n = 1:length(xdata) |
| 98 | + % length of arrow |
| 99 | + l = norm([0.1*udata(n), 0.1*vdata(n)]); |
| 100 | + |
| 101 | + % angle of arrow |
| 102 | + phi = atan2(vdata(n),udata(n)); |
| 103 | + |
| 104 | + % make barb with specified angular width, length is prop. to arrow |
| 105 | + barb = [... |
| 106 | + [-maxheadsize*l*cos(head_width), maxheadsize*l*sin(head_width)]; ... |
| 107 | + [0, 0]; ... |
| 108 | + [-maxheadsize*l*cos(head_width), -maxheadsize*l*sin(head_width)]; ... |
| 109 | + [nan, nan]; ... |
| 110 | + ]'; |
| 111 | + |
| 112 | + % affine matrix: rotate by arrow angle and translate to end of arrow |
| 113 | + barb_transformation = affine2d([... |
| 114 | + [cos(phi), sin(phi), 0]; ... |
| 115 | + [-sin(phi), cos(phi), 0]; ... |
| 116 | + [xdata(n) + 0.1*udata(n), ydata(n) + 0.1*vdata(n), 1]; |
| 117 | + ]); |
| 118 | + |
| 119 | + % place barb at end of arrow |
| 120 | + barb = transformPointsForward(barb_transformation, barb')'; |
| 121 | + |
| 122 | + % add barb to plot data, inserting is optimized in matlab >2010 |
| 123 | + for col = 1:4 |
| 124 | + obj.data{quiverIndex}.x(end+1) = barb(1,col); % point 1 |
| 125 | + obj.data{quiverIndex}.y(end+1) = barb(2,col); |
| 126 | + end |
| 127 | + end |
| 128 | +end |
| 129 | + |
| 130 | +%-------------------------------------------------------------------------% |
| 131 | + |
91 | 132 | %-scatter showlegend-%
|
92 | 133 | leg = get(quiver_data.Annotation);
|
93 | 134 | legInfo = get(leg.LegendInformation);
|
|
0 commit comments