Package 'CirclesIntersections'

Title: Algorithm for Computation of the Intersection Areas of N Circles
Description: Implementation of Librino, Levorato, and Zorzi (2014) <doi:10.1002/wcm.2305> algorithm for computation of the intersection areas of an arbitrary number of circles.
Authors: Hugo Salinas [aut, cre]
Maintainer: Hugo Salinas <[email protected]>
License: MIT + file LICENSE
Version: 1.1
Built: 2025-02-13 03:25:42 UTC
Source: https://github.com/hugosal/circlesintersections

Help Index


Auxiliary functions for computing circle intersection areas

Description

'intersection_two_circles()' Function for the the area of intersection of two circles.

'intersection_three_circles()' Function for the area of intersection of three circles.

Usage

intersection_two_circles(centers_x, centers_y, radii)

intersection_three_circles(centers_x, centers_y, radii)

Arguments

centers_x, centers_y, radii

Numeric vectors of length N with the x, y coordinates of the center, and the radius of the circles.

Value

The area of intersection of the circles is computed.


Implementation of Librino's algorithm for computing circle intersection areas

Description

This function computes the exclusive areas of intersection of N circles.

Usage

Librino_N(centers_x, centers_y, radii)

Arguments

centers_x, centers_y, radii

Numeric vectors of length N with the x, y coordinates of the center, and the radius of the circles.

Details

This is an implementation of Librino, Levorato, and Zorzi (2014) algorithm for computation of the intersection areas of an arbitrary number of circles.

Value

A list of length N containing the areas of exclusive intersection. The position of each element in the list indicates the number of intersecting circles. The first element of the list corresponds to the area of non-overlap of every circle, the second element is the pairwise area of intersection. Up to the last element of the list which corresponds to the area of intersection of all circles. Each of the elements of the list is a named numeric vector corresponding to the area of intersection between a set of circles. The names of the vector indicate the number of the circles in the intersection.

Author(s)

Hugo Salinas [email protected].

References

Librino, F., Levorato, M., & Zorzi, M. (2014). An algorithmic solution for computing circle intersection areas and its applications to wireless communications. Wireless Communications and Mobile Computing, 14, 1672–1690.

Examples

# Example of intersection areas including a Reuleaux triangle
x <- c(0, 1, 0.5)
y <- c(0, 0, sqrt(1-0.5**2))
radii <- c(1, 1, 1)
intersections <- Librino_N(centers_x = x, centers_y = y, radii = radii)
intersections
# Example with more circles
x2 <- c(0, 4, 2, 4, 5)
y2 <- c(1, 5, 4, 2, 1)
radii2 <- c(1, 4 ,2, 2, 1)
intersections2 <- Librino_N(centers_x = x2, centers_y = y2, radii = radii2)
intersections2

Simple validation test of the output of Librino_N()

Description

Checks if the sum of the areas of intersection of each circle adds to the total area of the circle, as it should.

Usage

validate_Librino(librino, radii)

Arguments

librino

A named numeric vector with the from resulting from [Librino_N()]

radii

Numeric vectors of length N with the radius of each circle.

Value

TRUE if all the partitions of the circles add to their total area, else a numeric vector with the number of the circles that failed this test.

Author(s)

Hugo Salinas [email protected].

Examples

# Example of intersection areas including a Reuleaux triangle
x <- c(0, 1, 0.5)
y <-c(0, 0, sqrt(1-0.5**2))
radii <- c(1, 1, 1)
intersections <- Librino_N(centers_x = x, centers_y = y, radii = radii)
validate_Librino(librino = unlist(intersections, use.names = TRUE), radii = radii)