- Do you have a 14 by 4 list of line segment endpoints (2 x,y end points per line segment)?
- Or do you have a digital image with the lines burned in as pixels?
- Or do you have the equations of the lines (slopes and intercepts)?
How to filter out lines that intersect other lines?
3 views (last 30 days)
Show older comments
I have about 14 lines stored in a matrix but are not plotted, and these lines create 84 intersections. So I am plotting 84 lines that emanate from the origin and connect to each of the points of intersection. Some of these lines travel a while to reach the intersection, and a few travel a short distance and do not cross any other lines before reaching the point of intersection. Is there any way to filter out all of the lines that cross other lines, and only keep the unobstructed lines plotted?
0 Comments
Answers (1)
Image Analyst
on 19 Jun 2015
How are they stored?
If it's an image, you can use bwmorph() with the 'branchpoints' option to find crossings.
2 Comments
Image Analyst
on 19 Jun 2015
Aditya, unless the lines are parallel, then they will cross. Check column 1 for duplicates using sort() and diff(), or using unique(), or just == operator.
To find the crossing points, it's just simple high school algebra. You have two lines, so set them equal to each other to find the common x point
ax + b = cx + d
(a-c)x = d-c
x = (d-c)/(a-c)
So don't you think you could add 13 rows where you'll give the x value of the crossing point for each of the other points? Sure you could - it's easy . I have confidence in you. Let us know if you can't. Then to get the y values, just stick that x into either of the two equations.
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!