I
I
ivandzemianchyk2014-06-18 11:44:42
Mathematics
ivandzemianchyk, 2014-06-18 11:44:42

How to check if lines create a closed geometric shape?

And how to choose from a variety of shapes the most similar to a rectangle?
In the project, the task has reached the point where I have a lot of lines and I need to choose from this set those that together represent a rectangle (or some similar figure, for example, meals with a measure of similarity of a figure to a rectangle)
I would be grateful for an answer to any question :
1. How to check if the figure represented by the intersection of the n-th number of lines is closed?
2. How can you check how similar a given figure is to a rectangle?
any help would be much appreciated
Edit:
Working in 2D space.
The line is described by two points. Can be described in any other way.
The lines are NOT parallel and NOT perpendicular, i.e. there is no perfect rectangle

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
hazestalker, 2014-06-18
@ivandzemianchyk

I will explain roughly
1. If the lines intersect, then you need to find the points of their intersection. Then (starting from one point) check whether the lines intersecting the first two, belonging to our point
2, intersect. Since we have the coordinates of the vertices, we can calculate the angles of this figure. Three corners or two opposite ones = 90, which means a rectangle + the same length of edges - a square
Any shape can be determined in the corners
Contact us if you need help)

A
AxisPod, 2014-06-18
@AxisPod

Not to start with what to decide what a line is. It is a segment, a ray or a straight line.
Next, it would be necessary to determine the space of what dimension they are located.
Well, three, suppose that the plane (as a consequence of image processing), then assume that the lines are segments based on the previous assumption.
As a result, knowing the coordinates it is very difficult not to understand whether they intersect or not. Compare with each other in pairs, a total of 8 comparisons, determine the intersection points, and angles, and for all this, you won’t believe, a school mathematics course is enough.

M
Mikhail Krinitsky, 2015-01-01
@mbrdancer

If the word "line" means exactly an infinite length of a straight line, and at the same time all the lines are not parallel, then I do not see a particular problem in question No. 1. Any two non-parallel lines must intersect. The set of points of pairwise intersection of the existing lines can be necessarily numbered, because there are a finite number of them.
For the purposes of constructing a polygon on these points - you can, for example, calculate the center of mass of all these intersection points, put the origin of the polar coordinate system in it and number them counterclockwise. So we get a sequence of non-intersecting segments that make up the polygon. And yes, this broken line will be closed. The question of the coincidence of angles for some set of points is solved by checking, adjusting the accuracy of calculations, or by shifting the beginning of the polar SC. The question of belonging of more than two points to one straight line is solved by checks and is of no fundamental importance.
True, with all this, it is possible to guarantee that the resulting polygon will be convex only for the case of three straight lines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question