I am trying to plot an arc of circle using three points in Rstudio, and I got this image
But, as you see the arc is not really smooth, as you see the “zigzags” within the path. How can we remove them. Here is part of my code:
plot_arc <- function(C, r, P1, P2, P3) {
t <- seq(atan2(P1[2] - C[2], P1[1] - C[1]), atan2(P2[2] - C[2], P2[1] - C[1]), length.out = 100000)
x <- C[1] + r * cos(t)
y <- C[2] + r * sin(t)
data <- data.frame(x = x, y = y)
p <- ggplot() +
geom_path(data = data, aes(x = x, y = y), color = "blue", size=1.) +
geom_point(aes(x = P1[1], y = P1[2]), color = "red", size = 3) +
geom_point(aes(x = P2[1], y = P2[2]), color = "green", size = 3) +
geom_point(aes(x = P3[1], y = P3[2]), color = "yellow", size = 3) +
coord_fixed()
print(p)
}
plot_arc(C_optimal, r_optimal, P1, P2, P3)