#' Compute circumcentre given three points
#'
#' @param point1_coord A vector of vertice 1 coordinate, where point1_coord[1] is the X-axis coordinate while point1_coord[2] is the Y-axis coordinate.
#' @param point2_coord A vector of vertice 2 coordinate, where point1_coord[1] is the X-axis coordinate while point1_coord[2] is the Y-axis coordinate.
#' @param point3_coord A vector of vertice 3 coordinate, where point1_coord[1] is the X-axis coordinate while point1_coord[2] is the Y-axis coordinate.
#' @export
compute_circumcentre_givenThreePoints <- function(point1_coord=c(0,0),point2_coord=c(1,1),point3_coord=c(-1,1)){
### Summary:
### Computes the coordinates of circumcentre given three points coordinates
# 1) Computing the coefficients of line perpendicular relative to line 1-2 and intersecting with the midpoint between point1 and point2
m1 <- compute_PerpendicularSlopeAndIntercept_givenTwoPoints(point1_coord=point1_coord, point2_coord=point2_coord)[1]
int1 <- compute_PerpendicularSlopeAndIntercept_givenTwoPoints(point1_coord=point1_coord, point2_coord=point2_coord)[2]
# 2) Computing the coefficients of line perpendicular relative to line 2-3 and intersecting with the midpoint between point2 and point3
m2 <- compute_PerpendicularSlopeAndIntercept_givenTwoPoints(point1_coord=point2_coord,point2_coord = point3_coord)[1]
int2 <- compute_PerpendicularSlopeAndIntercept_givenTwoPoints(point1_coord=point2_coord,point2_coord = point3_coord)[2]
# 3) Computing the coordinates of circumcentre
x <- (int2 - int1) / (m1 - m2)
y <- m1 * x + int1
o <- c(x,y)
names(o) <- c("x","y")
return(o)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.