math_circle_from3points | R Documentation |
calculate circle using 3 points.The function returns a tibble (data frame) or a named vector with the centre point and the radius.
math_circle_from3points(x)
x |
matrix with 3 rows of points and 2 columns with the coordinates. |
Returns data frame with centre coordinates and Radius.
Florian Wagner florian.wagner@wagnius.ch
x <- matrix(c(c(-2.23 , 4.389 ),
c(-1.001,-3.23 ),
c( 15.5,-7.2365)),
dimnames = list(c("x","y"),paste0("x",1:3)),
ncol = 3)|>t()
math_circle_from3points(x)
library(tidyverse)
library(ggforce)
ggplot()+
geom_point(data = as.data.frame(x),aes(x,y), color = "blue", size = 1.5)+
geom_point(data = math_circle_from3points(x),aes(x_center,y_center))+
geom_label(data = math_circle_from3points(x),
aes(x_center,y_center,label = "center"), nudge_y = 1.5)+
geom_circle(data = math_circle_from3points(x),
aes(x0 = x_center , y0 = y_center,r = radius))+
geom_label(data = as.data.frame(x),
aes(x,y,label = paste("input:",row.names(as.data.frame(x)))), nudge_y = 1.5)+
geom_hline(yintercept = 0)+
geom_vline(xintercept = 0)+
scale_x_continuous(limits = c(-5,22))+
coord_fixed()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.