secant_intersections: Calculate Intersections of Circle by a Straight Line

View source: R/secant_intersections.R

secant_intersectionsR Documentation

Calculate Intersections of Circle by a Straight Line

Description

The circle is centered a (0, 0) and has radius r, the line is given in slope-intercept from.

Usage

secant_intersections(a, b, r, verbose = FALSE)

Arguments

a

The secant's intercept.

b

The secant's slope.

r

The circle's radius

verbose

Be verbose?

Value

A matrix of x und y values. For a tangent, both rows are identical, for a straight line missing the circle, a matrix of NA.

Examples

secant_intersections(a = 0, b = 1, r = 2)
# A tangent
secant_intersections(a = 2, b = 0, r = 2, verbose = TRUE)
# Missing the circle
secant_intersections(a = 3, b = 0, r = 2)
# Creating a circle boundary approximation
plot(0, 0, col = "red", pch = "+",
     xlim = c(-2, 2),
     ylim = c(-2, 2))
for (i in seq(-1, 1, by = 0.01)) {
         points(secant_intersections(Inf, i, 1), pch = "+")
}

treePlotArea documentation built on June 22, 2024, 6:57 p.m.