circleCenter: Find the center of a circle

View source: R/geom_findCenter.R

circleCenterR Documentation

Find the center of a circle

Description

Computes the coordinates of the center point of a circle defined, in 3D space, by 3 points on the circumference.

Usage

circleCenter(p)

Arguments

p

A 3x3 matrix-like object containing 3D coordinates of points defining the circumference (one xyz coordinate per row)

Value

A data.frame containing the x,y,z coordinates of the circle center. An error will be returned if the input points are collinear or duplicated.

Author(s)

Cornel M. Pop

Examples

p <- data.frame(x=c(1, 4, 5), y=c(0, 5, 1), z=c(1.4, -4, 4))
res <- circleCenter(p)
# distance from computer center to input point 1
dist(rbind(res, p[1,]), method="euclidean")
# distance from computer center to input point 2
dist(rbind(res, p[2,]), method="euclidean")
# distance from computer center to input point 3
dist(rbind(res, p[3,]), method="euclidean")

cornelmpop/Lithics3D documentation built on Feb. 10, 2024, 11:54 p.m.