Skip to content

Commit

Permalink
Specify texture period in data coordinate units
Browse files Browse the repository at this point in the history
  • Loading branch information
keithfma committed Oct 3, 2016
1 parent 9b8a4f4 commit 7e1d0bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion even_stream_arrow.m
Expand Up @@ -18,7 +18,7 @@
% 'ArrowLength': arrow head length in pixels, default = 20
% 'ArrowTipAngle': arrow head tip angle in degrees, default = 20
% 'ArrowBaseAngle': arrow head base angle in degrees, default = 10
% 'ArrowSpace': arrow head spacing along line in coordinate unite,
% 'ArrowSpace': arrow head spacing along line in data coordinate units,
% default = 5% of minimum coordinate axis range
%
% Returns:
Expand Down
5 changes: 2 additions & 3 deletions even_stream_demo.m
Expand Up @@ -99,15 +99,14 @@

% compute
tic
% xy = even_stream_data(xx, yy, dzdx, dzdy, 0.003, 0.0015);
xy = even_stream_data(xx, yy, dzdx, dzdy, 0.05, 0.025);
xy = even_stream_data(xx, yy, dzdx, dzdy, 0.003, 0.0015);
fprintf('even_stream_data: %.3f s elapsed\n', toc);

% plot
tic
hf = figure;
hf.Name = sprintf('%s: even stream texture', mfilename);
even_stream_texture(xy, 'LineWidth', 1, 'Period', 20);
even_stream_texture(xy, 'LineWidth', 1, 'Period', 0.020*range(vv));
title('even\_stream\_texture');
ax = gca;
ax.XTick = [];
Expand Down
11 changes: 8 additions & 3 deletions even_stream_texture.m
Expand Up @@ -12,7 +12,8 @@
%
% Optional Parameters (Name, Value):
% 'LineWidth': line width, as in the plot(), default = 0.5
% 'Period': length of periodic pattern in # points, default = 20;
% 'Period': length of periodic pattern in data coordinate spacing,
% default = 20% of minimum coordinate axis range
%
% Returns:
% hh = Vector of graphics objects for streamlines
Expand All @@ -32,15 +33,19 @@
parser.KeepUnmatched = false;

parser.addParameter('LineWidth', 0.5);
parser.addParameter('Period', 20);
parser.addParameter('Period', 0.20*min(range(xy)));

parser.parse(varargin{:});
line_width = parser.Results.LineWidth;
period = parser.Results.Period;

validateattributes(period, {'numeric'}, {'scalar', 'positive', 'integer'}, ...
validateattributes(period, {'numeric'}, {'scalar', 'positive'}, ...
mfilename, 'period');

% convert period to approximate number of points
mean_segment_length = nanmean(sqrt(sum(diff(xy).^2, 2)));
period = round(period/mean_segment_length);

% reformat streamlines as segments
num_segments = size(xy, 1)-2*sum(isnan(xy(:,1)))-1;
x_segment = nan(num_segments, 2);
Expand Down

0 comments on commit 7e1d0bc

Please sign in to comment.