segments_to_vertices | R Documentation |
This function takes a data frame of arcs (segments) and constructs an ordered sequence of vertices to outline a connected, non-intersecting polygon.
segments_to_vertices(arcs_df)
arcs_df |
A data frame containing arc information with columns:
|
This function iteratively selects arcs that connect to form a polygon. If an arc’s endpoint does not match any available arc’s start or endpoint, it selects the nearest arc using a nearest-neighbor search. Segments that would cause intersections are removed. If the constructed polygon closes on itself, it terminates the process.
A data frame (outline_df
) containing the vertices (x
, y
coordinates and idx
)
that form the ordered outline of the polygon.
# Sample data frame of arcs
arcs_df <- data.frame(
x1 = c(0, 1, 2),
y1 = c(0, 1, 0),
x2 = c(1, 2, 0),
y2 = c(1, 0, 0),
idx = c(1, 2, 3)
)
segments_to_vertices(arcs_df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.