From 8b5ecd62e93a33cf88152af31b5f14b81178cdf2 Mon Sep 17 00:00:00 2001 From: Francesco Nattino Date: Mon, 28 Oct 2024 10:14:27 +0100 Subject: [PATCH] drop get_angle --- R/stroke.R | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/R/stroke.R b/R/stroke.R index 043abc0..696eace 100644 --- a/R/stroke.R +++ b/R/stroke.R @@ -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") @@ -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 }