Curve intersections

버전 1.5.0.0 (2.47 KB) 작성자: NS
Fast computation of intersections and self-intersections of curves using vectorization.
다운로드 수: 30K
업데이트 날짜: 2010/9/24

라이선스 보기

While a few other functions already exist in FEX that compute the intersection points of curves, this short piece of code was written with speed being the highest priority. No loops are used throughout, taking full advantage of MATLAB's vectorization capabilities

I welcome any comments, suggestions, bug reports etc.

------------------------------------------------------------------------------

INTERX Intersection of curves
P = INTERX(L1,L2) returns the intersection points of two curves L1
and L2. The curves L1,L2 can be either closed or open and are described
by two-row-matrices, where each row contains its x- and y- coordinates.
The intersection of groups of curves (e.g. contour lines, multiply
connected regions etc) can also be computed by separating them with a
column of NaNs as for example

L = [x11 x12 x13 ... NaN x21 x22 x23 ...;
y11 y12 y13 ... NaN y21 y22 y23 ...]

P has the same structure as L1 and L2, and its rows correspond to the
x- and y- coordinates of the intersection points of L1 and L2. If no
intersections are found, the returned P is empty.

P = INTERX(L1) returns the self-intersection points of L1. To keep
the code simple, the points at which the curve is tangent to itself are
not included. P = INTERX(L1,L1) returns all the points of the curve
together with any self-intersection points.

Example:
t = linspace(0,2*pi);
r1 = sin(4*t)+2; x1 = r1.*cos(t); y1 = r1.*sin(t);
r2 = sin(8*t)+2; x2 = r2.*cos(t); y2 = r2.*sin(t);
P = InterX([x1;y1],[x2;y2]);
plot(x1,y1,x2,y2,P(1,:),P(2,:),'ro')

인용 양식

NS (2024). Curve intersections (https://www.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2008a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Fit Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.5.0.0

Fixed a bug identified by Liu Minjie that would sometimes occur for two-point line segments.

1.3.0.0

Faster execution & better memory management

1.0.0.0