Take the Data Structures and Algorithms in Python course
A transversal line of a set of line segments in a plane is a straight line that passes through all the line segments.
In the first blog post of this series, we solved the vertical line segment transversal problem. Here, we briefly summarize the problem and the method used to solve it, before moving to the next problem in this series.
Problem statement: For a set of
We mapped the vertical line segment transversal problem to a linear program and solved it using SciPy's optimize.linprog
function.
In case the line segments are not confined to be vertical but can take any orientation, the problem becomes trickier, as it is unclear how to formulate it as a linear program. To solve it, we take help from a powerful tool from computational geometry: the concept of duality. Before going into the details of duality, let's see the line segment transversal problem in its general setting.
Problem statement: For a set of
To solve this problem, we use duality transforms.
A point and a line lying in a plane have two parameters. A point is characterized by its
Consider a line
Interesting relations emerge between geometric objects in the primal plane and their transforms in the dual plane. Let's look at the two basic relations.
By definition, the dual of a line
The dual of a point
As shown above, the lines
As the three lines pass through the point
We can rearrange the equations as follows:
Concluding that in the dual plane, the points
Next, we'll look at the properties of dual transform. We will use some of these properties to derive the dual transform of a line segment.
Let
Incidence preservation: The duality transform preserves incidence. In the primal plane,
It is easy to see why this is true. Let
The equation above can be rearranged as below:
This indicates that the dual of line
Note: The collinearity of dual points of lines that have a common point of intersection is a direct consequence of incidence preservation.
Order preservation: The duality transform preserves order. The point
Consider a point
The inequality relation above can be rearranged as follows:
This proves that the dual of line
A line segment
In the dual plane in the figure above, the dual lines
To decide which of the double wedges corresponds to
The dual of a line segment is the left-right double wedge defined by the dual lines of its endpoints.
In the dual plane, a point that lies within the double wedge corresponding to
This is true because any line that intersects the line segment
The transversal line of a set of line segments is the overlapping region of their corresponding double wedges in the dual plane. If the line segments do not admit a transversal line, the overlapping region of the corresponding double wedges will be empty.
Let's see some examples:
Now, we'll discuss the algorithm that finds the region of overlap of all the double wedges or reports that such a region does not exist.
For
In geometry, the subdivision of a plane into several regions by a collection of lines is known as a line arrangement, where each region is known as a face.
The boundaries of the faces are chains of straight-line edges.
Some of these chains are closed, defining faces that are convex polygons, and others are open.
The goal is to find a face that lies in all the double wedges in the line arrangement defined by the bounding lines of double wedges.
Here is an example with two double wedges and the corresponding line arrangement. On each face, the number of double wedges that contain it are labeled.
The line arrangement for a collection of
In the line arrangement, each edge
For each face
Starting from a face
Starting from
Free Resources