I thought I'd answer this myself just in case anyone else with a similar problem ever stumbles on this.
Using the above advice on converting my Cartesian coordinates to polar coordinates, I've made a function which calculates a minimum enclosing circle around the x,y coordinates, and divides this circle into a user-defined number of 'grid' cells with equal area, before assigning a unique ID to each cell and determining which cell each x,y point is in.
Here's the function, where x and y are both arrays containing the raw x,y coordinates, and n_radials and n_slices are the desired number of longitudinal and radial sectors to divide the circular arena into.
require(shotGroups)
getCellID <- function(x, y, n_radials, n_slices) {
# first, calculate radii of all radials
#--------------------------------------
xy <- matrix(c(x, y), ncol=2)
xy <- na.omit(xy)
#get minimum enclosing circle to find outer radius
circle <- getMinCircle(xy)
midX <- circle$ctr[1]
midY <- circle$ctr[2]
outer_radius <- circle$rad
#calculate radii of each internal radial
radii <- c()
for(i in 1:n_radials){
radii_i <- outer_radius * sqrt(i/n_radials)
radii <- rbind(radii, radii_i)
}
# then, convert x,y to polar coordinates
#---------------------------------------
#normalise raw x,y coordinates so relative to centre of circle
x <- x - midX
y <- y - midY
#convert Cartesian coordinates to polar
polar_radii <- sqrt(x^2 + y^2)
polar_theta <- atan2(y, x) / pi * 180
# and lastly, determine which 'grid' cell each point lies in
#-----------------------------------------------------------
#determine which SLICE
slice_breaks <- seq(-180, 180, 360 / n_slices)
sliceID <- cut(polar_theta, slice_breaks)
levels(sliceID) <- c(1:n_slices)
#determine which RADIAL
radial_breaks <- c(0, radii)
radialID <- cut(polar_radii, radial_breaks)
levels(radialID) <- c(1:nrow(radii))
#determine which CELL
cellID <- n_slices * (as.numeric(radialID) - 1) + as.numeric(sliceID)
#-------
# Output
return(cellID)
}
I'd still be interested in any critical insight or ways to improve this function!