From 08ed2088dc1e69797bde2bdc34040ee8f4494c23 Mon Sep 17 00:00:00 2001 From: Francesco Nattino Date: Fri, 22 Nov 2024 11:30:48 +0100 Subject: [PATCH] numerical errors can get cos_theta slightly outside -1;1 boundary --- R/stroke.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/stroke.R b/R/stroke.R index b12fd85..0067463 100644 --- a/R/stroke.R +++ b/R/stroke.R @@ -226,7 +226,7 @@ interior_angle <- function(v, p1, p2) { norm1 <- sqrt(dx1^2 + dy1^2) norm2 <- sqrt(dx2^2 + dy2^2) cos_theta <- dot_product / (norm1 * norm2) - angle <- acos(cos_theta) + angle <- acos(round(cos_theta, 6)) return(angle) }