Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This code finds co-linear groups of lines. </p> <p><img src="https://i.stack.imgur.com/v7i19.png" alt="enter image description here"></p> <pre><code>theta = zeros(length(lines),1); rho = zeros(length(lines),1); for k = 1:length(lines) xy = [lines(k).point1; lines(k).point2]; plot(xy(:,1),xy(:,2),'LineWidth',1,'Color','green'); plot(xy(1,1),xy(1,2),'x','LineWidth',1,'Color','yellow'); plot(xy(2,1),xy(2,2),'x','LineWidth',1,'Color','red'); %text(xy(1,1),xy(1,2),[' ' num2str(k)],'fontsize',10,'color',[1 1 1]); theta(k) = lines(k).theta; rho(k) = lines(k).rho; end theta_tolerance = 2; theta2 = abs(bsxfun(@minus, theta, theta')) &lt;= theta_tolerance; theta2(1:size(theta2,2)+1:numel(theta2)) = 0; % zero diagonal rho_tolerance = 1; rho2 = abs(bsxfun(@minus, rho, rho')) &lt;= rho_tolerance; rho2(1:size(rho2,2)+1:numel(rho2)) = 0; % zero diagonal rhotheta2 = sparse(rho2 &amp; theta2); [nc, C] = graphconncomp(rhotheta2); paired = ismember(C,find(hist(C,1:max(C))&gt;1)); % paired lines colors=get(gcf,'DefaultAxesColorOrder'); for line=find(paired) xy = [lines(line).point1; lines(line).point2]; plot(xy(:,1),xy(:,2),':','LineWidth',4,'Color',colors(C(line),:)); text(xy(1,1),xy(1,2),num2str(C(line)),'fontsize',20,'Color',colors(C(line),:)); end </code></pre> <p>It doesn't take care of overlapping. It is not clear how want to treat a case with 3 co-linear segments, where the first segment and the second segment intersect? Do you need to consider both the set containing the first and the third and the set containing the second and the third segment?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload