Skip to contents

This function calculates the intersection points between an ellipse and a straight line that passes through the center of the ellipse with a given slope. It handles both regular slopes and vertical lines (slope = Inf).

Usage

EllipseLine_intersection(center, radius, lineslop)

Arguments

center

A numeric vector of length 2 specifying the center of the ellipse (h, k).

radius

A numeric vector of length 2 specifying the semi-axes of the ellipse (a, b).

lineslop

A numeric value specifying the slope m of the line. Use Inf for vertical lines.

Value

A 2x2 matrix with row names "p1" and "p2", and column names "x" and "y", representing the coordinates of the two intersection points.

Examples

if (FALSE) { # \dontrun{
  # Regular slope
  EllipseLine_intersection(center = c(0, 0), radius = c(3, 2), lineslop = 1)

  # Vertical line
  EllipseLine_intersection(center = c(0, 0), radius = c(3, 2), lineslop = Inf)
} # }