Fast and Robust Curve Intersections

版本 (5.5 KB) 作者: Douglas Schwarz
Computes intersection points of two curves.
43.1K 次下载
更新时间 2024/5/31


编者注: This file was selected as MATLAB Central Pick of the Week

This function computes the (x,y) locations where two curves intersect. The curves can be broken with NaNs or have vertical segments. It is also very fast (at least on data that represents what I think is a typical application).


Douglas Schwarz (2024). Fast and Robust Curve Intersections (, MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2009a
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!
版本 已发布 发行说明

I just learned about the paged matrix functions from Mike Croucher's blog and immediately replaced backslash with pagemldivide for a significant speedup.

This version uses implicit expansion (or bsxfun in slightly older MATLAB versions) to compute the line segments that might overlap. When the number of line segments is large, it uses a different algorithm to avoid forming large matrices.

Fixed bug that my previous "bug fix" failed to fix.

Fixed bug identified by Rodrigo Portugal. No longer fails when there are no intersections and you need 4 outputs.

Added ability to find self-intersections of one curve.