Skip to content

Commit

Permalink
drop get_angle
Browse files Browse the repository at this point in the history
  • Loading branch information
fnattino committed Oct 28, 2024
1 parent 576022d commit 8b5ecd6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions R/stroke.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ best_link <- function(nodes, segments, links, angle_threshold = 0) {
return(linked_nodes)
}

get_angle <- function(vertex_id, p1_id, p2_id) {
# calculate interior angle
angle <- interior_angle(nodes[vertex_id, ], nodes[p1_id, ], nodes[p2_id, ])
return(angle)
}

best_links <- array(integer(), dim = dim(segments))
colnames(best_links) <- c("start", "end")

Expand All @@ -147,14 +141,18 @@ best_link <- function(nodes, segments, links, angle_threshold = 0) {
# find angles formed with all segments linked at start point
linked_segs <- get_linked_segments(iseg, start_node)
linked_nodes <- get_linked_nodes(start_node, linked_segs)
angles <- get_angle(start_node, end_node, linked_nodes)
angles <- interior_angle(nodes[start_node, ],
nodes[end_node, ],
nodes[linked_nodes, ])
best_link <- get_best_link(angles, linked_segs, angle_threshold_rad)
if (length(best_link) > 0) best_links[iseg, "start"] <- best_link

# find angles formed with all segments linked at end point
linked_segs <- get_linked_segments(iseg, end_node)
linked_nodes <- get_linked_nodes(end_node, linked_segs)
angles <- get_angle(end_node, start_node, linked_nodes)
angles <- interior_angle(nodes[end_node, ],
nodes[start_node, ],
nodes[linked_nodes, ])
best_link <- get_best_link(angles, linked_segs, angle_threshold_rad)
if (length(best_link) > 0) best_links[iseg, "end"] <- best_link
}
Expand Down

0 comments on commit 8b5ecd6

Please sign in to comment.