% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/R-trajectory.R
\name{build_one_line}
\alias{build_one_line}
\title{Build a single line of spots along a segment}
\usage{
build_one_line(df_rest, A, B, top_n = 19, max_dist = NULL)
}
\arguments{
\item{df_rest}{A data frame of candidate spots containing at least columns
`x` and `y`.}

\item{A}{A data frame with columns `x` and `y` defining endpoint A of the
segment. If it contains multiple rows, only the first row is used.}

\item{B}{A data frame with columns `x` and `y` defining endpoint B of the
segment. If it contains multiple rows, only the first row is used.}

\item{top_n}{Integer; number of closest spots to keep (default `19`).
If `NULL`, no top-N truncation is applied.}

\item{max_dist}{Numeric; if not `NULL`, only spots with distance to the
segment `<= max_dist` are kept.}
}
\value{
A data frame of selected spots (subset of `df_rest`) ordered along
the
segment (in increasing `pos_on_seg`). The output includes the extra columns
added by
`build_one_trajectory()` (typically `dist_to_seg` and `pos_on_seg`).
}
\description{
Selects spots near the segment defined by endpoints `A` and `B` using
`build_one_trajectory()`, then orders the selected spots by their projection
parameter (from `A` to `B`). The result is returned as a data frame.
}
\details{
This function is a thin wrapper around `build_one_trajectory()` that returns
only the ordered `selected` data frame (and not the segment metadata).

It uses the base R pipe `|>` and `dplyr::arrange()`.
}
\examples{
df <- data.frame(
  x = c(0, 1, 2, 3, 4, 2),
  y = c(0, 0, 0, 0, 0, 1),
  id = 1:6
)
A <- data.frame(x = 0, y = 0)
B <- data.frame(x = 4, y = 0)

build_one_line(df, A, B, top_n = 5)

}
