-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotSegments.m
More file actions
39 lines (34 loc) · 1.13 KB
/
Copy pathplotSegments.m
File metadata and controls
39 lines (34 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function plotSegments(lineSegments, lineSpec, lineWidth)
%plotSegments Plot 2D line segments with equal aspect ratio and margins.
%
% plotSegments(lineSegments, lineSpec, lineWidth) takes a .NET list of
% LinFloat64Vector2D or Float64LineSegment2D objects
%
% The function plots all line segments in the current figure.
%
% Author: Ahmad H. Eid
% Date: 2025-11-10
% Version: 1.1
%---------------------------%
% Validate input arguments %
%---------------------------%
if nargin < 3
lineWidth = 1;
end
if nargin < 2
lineSpec = 'b-';
end
if nargin < 1
error('plotSegments:MissingInput', ...
'Input argument "lineSegments" is required.');
end
%---------------------------------------%
% Prepare data for vectorized plotting %
%---------------------------------------%
% Create X and Y arrays with NaN separators
[X, Y] = getXyForPlot(lineSegments);
%---------------------------------------%
% Plot all line segments efficiently %
%---------------------------------------%
plot(X(:), Y(:), lineSpec, 'LineWidth', lineWidth);
end