octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #65422] Octave patch does not plot patch if po


From: Liang Tang
Subject: [Octave-bug-tracker] [bug #65422] Octave patch does not plot patch if points create a straight line
Date: Wed, 20 Mar 2024 06:41:00 -0400 (EDT)

Follow-up Comment #4, bug #65422 (group octave):

I tried to find a workaround.  But it did not work.  Line is significantly
slower than patch.  Thanks.  

This example shows the elapsed time to draw similar number of line segments
using patch and line are very different. Patch is faster.  The performance of
using all lines in a single line command does not show much improvement over
drawing the many lines one-by-one.  

% line 
n=5000; n=1000; % adjust as needed 
tt=reshape(linspace(0, 2*pi, n), [],1); rr=100; 
x=rr*sin(tt); y=rr*cos(tt); z=sin(tt); 
x_ave=mean(x);y_ave=mean(y); z_ave=mean(z);

x=[x;x_ave]; y=[y;y_ave]; z=[z;z_ave];

figure('name', '1 All-in-one.  Really fast'); axs=axes; hold on;
%plot3(x,y,z); hold on;
faces=[ (n+1)*ones(n-1,1) reshape([1:1:n-1],[],1)  reshape([2:1:n],[],1)]; 
vert =[[1:size(x,1)]'  x y z]; 
h_tri=patch('Vertices',     vert(:,2:end),'Faces', faces,'FaceColor',[1 0
0],'EdgeColor', [1 0 0],'FaceAlpha', 0.2, 'LineWidth', 1 ); whos h_tri %
single handle

figure('name', '2 One-by-one.  Really slow, expected.'); axs=axes;  hold on; %
plot3(x,y,z);
vert =[[1:size(x,1)]'  x y z]; 
for ii=1:n-1, 
    faces=[ (n+1) ii  ii+1]; 
    h_tri=patch('Vertices',     vert(:,2:end),'Faces', faces,'FaceColor',[1 0
0],'EdgeColor', [1 0 0],'FaceAlpha', 0.2, 'LineWidth', 1 ); % mutiple handles
end; whos h_tri

% number of line segments is about 50% of patch. 

figure('name', '3 all lines in one is slow, surprisingly.'); plot3(x,y,z);
hold on; 
xd=[repmat(x_ave, 1, size(x,1)); reshape(x,1,[])];yd=[repmat(y_ave, 1,
size(x,1)); reshape(y,1,[])];zd=[repmat(z_ave, 1, size(x,1));
reshape(z,1,[])];
l=line(xd,yd,zd, 'color', 'r'); whos l  % multiple handles

figure('name', '4 separated lines is also slow, as expected.'); axs=axes;
plot3(x,y,z); hold on;
for ii=1:n, ll(ii)=line( [x_ave;x(ii)], [y_ave; y(ii)], [z_ave; z(ii)],
'color', 'r'); end; whos ll  % multiple handles





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65422>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]