Skip to content

Commit 0635f16

Browse files
committed
cleanup
1 parent dc3e604 commit 0635f16

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

plotly/plotlyfig_aux/handlegraphics/updateQuiver.m

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,23 @@
8989
%-------------------------------------------------------------------------%
9090

9191
%-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)
9597
% length of arrow
9698
l = norm([0.1*udata(n), 0.1*vdata(n)]);
9799

98100
% angle of arrow
99101
phi = atan2(vdata(n),udata(n));
100102

101-
% make barb with specified angular width and length prop. to arrow
103+
% make barb with specified angular width, length is prop. to arrow
102104
barb = [...
103105
[-maxheadsize*l*cos(head_width), maxheadsize*l*sin(head_width)]; ...
104106
[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]; ...
106109
]';
107110

108111
% affine matrix: rotate by arrow angle and translate to end of arrow
@@ -112,18 +115,14 @@
112115
[xdata(n) + 0.1*udata(n), ydata(n) + 0.1*vdata(n), 1];
113116
]);
114117

115-
% apply transformation to barb
118+
% place barb at end of arrow
116119
barb = transformPointsForward(barb_transformation, barb')';
117120

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
127126
end
128127

129128
%-------------------------------------------------------------------------%

0 commit comments

Comments
 (0)