|
64 | 64 | udata = reshape(quiver_data.UData,1,size(quiver_data.UData,1)*size(quiver_data.UData,1));
|
65 | 65 | vdata = reshape(quiver_data.VData,1,size(quiver_data.VData,1)*size(quiver_data.VData,1));
|
66 | 66 |
|
67 |
| -%------------------------------------------------------------------------% |
68 |
| -% JNJ: Need to implement the arrowheads!!! Bit of an oversight...! |
69 |
| -% Also, compare Python plotly arrowheads to the matlab arrowheads... |
70 |
| -% At the same time, we might make sure the line length adjusts |
71 |
| -% appropriately. |
72 |
| -% Might as well make arrowheads scaleable, too. |
73 | 67 | %------------------------------------------------------------------------%
|
74 | 68 |
|
75 | 69 | %-quiver x-%
|
|
94 | 88 |
|
95 | 89 | %-------------------------------------------------------------------------%
|
96 | 90 |
|
| 91 | +%-quiver barbs-% |
| 92 | +max_head_size = 0.15; % 'MaxHeadSize' scalar, matlab clips to 0.2 |
| 93 | +head_width = deg2rad(15); % 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? |
| 95 | + % length of arrow |
| 96 | + l = norm([0.1*udata(n), 0.1*vdata(n)]); |
| 97 | + |
| 98 | + % angle of arrow |
| 99 | + phi = atan2(vdata(n),udata(n)); |
| 100 | + |
| 101 | + % make barb with specified angular width and length prop. to arrow |
| 102 | + barb = [... |
| 103 | + [-0.5*l*cos(head_width), 0.5*l*sin(head_width)]; ... |
| 104 | + [0, 0]; ... |
| 105 | + [-0.5*l*cos(head_width), -0.5*l*sin(head_width)]; |
| 106 | + ]'; |
| 107 | + |
| 108 | + % affine matrix: rotate by arrow angle and translate to end of arrow |
| 109 | + barb_transformation = affine2d([... |
| 110 | + [cos(phi), sin(phi), 0]; ... |
| 111 | + [-sin(phi), cos(phi), 0]; ... |
| 112 | + [xdata(n) + 0.1*udata(n), ydata(n) + 0.1*vdata(n), 1]; |
| 113 | + ]); |
| 114 | + |
| 115 | + % apply transformation to barb |
| 116 | + barb = transformPointsForward(barb_transformation, barb')'; |
| 117 | + |
| 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; |
| 127 | +end |
| 128 | + |
| 129 | +%-------------------------------------------------------------------------% |
| 130 | + |
97 | 131 | %-scatter showlegend-%
|
98 | 132 | leg = get(quiver_data.Annotation);
|
99 | 133 | legInfo = get(leg.LegendInformation);
|
|
0 commit comments