Segment crossings

Find segment crossings and proximate points (e.g., for polygon intersection testing).
0 download
Aggiornato 15 dic 2025

Visualizza la licenza

% Syntax:
%
% [flag,pt,ipt] = segmentx(pt,iseg1,iseg2,tol);
% [flag,pt,ipt] = segmentx(pt,iseg1,iseg2);
%
% Inputs:
%
% pt: 2-column matrix of points ([x,y] coordinate pairs), in any
% sequencing order
%
% iseg1: 2-column matrix of first segments' end-point indices in the
% range 1:size(pt,1). iseg1(j,:) represents a line segment from
% pt(iseg1(j,1),:) to pt(iseg2(j,2),:).
%
% iseg2: 2-column matrix of second segments' end-point indices in the
% range 1:size(pt,1), same format as iseg1.
%
% tol: scalar, non-negative, proximity tolerance for point equality
% testing, OPTIONAL, default = 0. Points [x1,y1] and [x2,y2] are
% considered to be proximate if norm([x1-x2,y1-y2])<=tol.
%
% Outputs:
%
% flag: logical, true if any point in the first segment list is proximate
% to a point from the second segment list, excluding shared points.
% Points are "shared" if they have the same pt index in iseg1 and iseg2.
% (Equality of point coordinates in pt does not make them "shared".)
% Proximity testing between two segments sharing a single end point only
% considers proximate point pairs where one of the points is a segment
% end point.
%
% pt:same as input, but with rows added for proximate points
%
% ipt: array of intersection point indices in pt, of size
% [size(iseg1,1),size(iseg2,1),2] and in the range 0:size(pt,1). If
% segments iseg1(j1,:) and iseg2(j2,:) have (non-shared) proximate
% points, then one such point pair, pt1 from the first segment and pt2
% from the second segment, will be in the pt list with pt1 =
% pt(ipt(j1,j2,1),:) and pt2 = pt(ipt(j1,j2,2),:). If the segments have
% no such proximate points, then ipt(j1,j2,:) will be all-zero.

Cita come

Kenneth Johnson (2025). Segment crossings (https://it.mathworks.com/matlabcentral/fileexchange/182833-segment-crossings), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2025b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Tag Aggiungi tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.0.0