distanceToTarget: Calculates distances to a target point

View source: R/distanceToTarget.R

distanceToTargetR Documentation

Calculates distances to a target point

Description

Given a dataset of points, it computes the Euclidean distances from each point to a specified target point. The function also identifies contiguous segments of points that fall within a specified radius around the target.

Usage

distanceToTarget(data, target, targetRadious = 0)

Arguments

data

A matrix or data frame where each row represents a point in multi-dimensional space.

target

A numeric vector representing the coordinates of the target point.

targetRadious

A numeric value indicating the radius around the target point. Points within this radius are considered to be close to the target. Default is 0.

Value

A list containing:

distance

A numeric vector of distances from each point in 'data' to the 'target'.

r

A list with two components: 'start', indicating the starting indices of contiguous segments of points within the target radius, and 'length', indicating the lengths of these segments.

target_radious

The radius around the target point.

Examples

# Create an example data matrix
data <- matrix(c(1, 1, 2, 2, 3, 3), ncol = 2, byrow = TRUE)
target <- c(2, 2)
result <- distanceToTarget(data, target, targetRadious = 0)
print(result)

BioTrajectory documentation built on June 8, 2025, 11:54 a.m.