Program to connect points and merge colinear lines

조회 수: 7 (최근 30일)
Harold
Harold 2013년 5월 21일
I'm developing a program to connect a set of (x,y) points in a polygon so that the resulting cell array contains a list of line segments. Each row of this cell array contains two points, which describe the endpoints of each line segment of the polygon. Furthermore, if a line segment found to be connected to another line segment, a test is performed to determine if the lines are colinear. I've got this program nearly finished except for some errors in appending the cell array after testing positive for coplanar lines.
I've included comments within the code to help explain what I'm doing.

답변 (1개)

Image Analyst
Image Analyst 2013년 5월 21일
Do you have a question? If not, if you think it will be useful generally to people, then you can upload to the File Exchange when you're done. I do have a question. How can a bunch of lines in the x-y plane NOT be coplanar? As far as I can tell, they're all coplanar.
  댓글 수: 6
Harold
Harold 2013년 5월 21일
편집: Image Analyst 2013년 5월 24일
I've thought about using this but it won't work for polygon that have a dip. Image a triangle with a wedge taken out of the side. The convex hull will only draw a boundary that contains all the points. Actually my line connecting programming works. It's just that what I do afterwards won't work flawlessly unless I get rid of unnecessary points; i.e extra points from co-linear lines.
What I'm doing next is to create raster lines like what is shown here http://ars.els-cdn.com/content/image/1-s2.0-S016636151300002X-gr12.jpg
I've already developed code for this. First thing I do is take vertical lines spaced out at some spacing that I calculate dx = (xmax-xmin)/numdivision. I then just increment my x value by dx. I find all line segments where the current x value is between the x values of the line segments. I then calculate the y intersection value with these lines, using the equation of a line vectorized. Here's the part that messes up with the extra points. If the current x value happens to equal a x value of any line segments, the line is not included in the list for y intersection computation. If I can figure out another way of selecting the lines that get used in the y intersection calculation, then I don't need to get rid of the extra line segment points. However, I think that it would still benefit someone else and it's also better coding.
Harold
Harold 2013년 5월 24일
Ok, I think I have this program finished. I would still like to do some more testing with various polygon shapes and also with holes in the polygons. I would also still like to clean up the code a bit more because I do a couple cell2mat and mat2cell conversions. I want to see if I can re-write some of the operations I do as a cell function so I don't have to convert from cell to matrix to do them.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by