# distances: Point distance with C++ In SpaDES.tools: Additional Tools for Developing Spatially Explicit Discrete Event Simulation (SpaDES) Models

## Description

`pointDistance2` performs Pythagorean Theorem and `cbind`s all columns from `to` to new dists column. It is only defined for one point (`from`) to many (`to`) points. `pointDistance3` performs Pythagorean Theorem and is to be used internally within `distanceFromEachPoint` as an alternative to `.pointDistance`, where it does many points (`from`) to many (`to`) points, one `from` point at a time. The results are then `rbind`ed internally. It does not `cbind` extra columns from `to`.

## Usage

 ```1 2 3 4 5 6``` ```pointDistance2(to, from) pointDistance3(fromX, toX, fromY, toY, maxDistance) .pointDistance(from, to, angles = NA, maxDistance = NA_real_, otherFromCols = FALSE) ```

## Arguments

 `to` Numeric matrix with 2 or 3 columns (or optionally more, all of which will be returned), x and y, representing x and y coordinates of "to" cells, and optional "id" which will be matched with "id" from `from`. Default is all cells. `from` Numeric matrix with 2 or 3 or more columns. They must include x and y, representing x and y coordinates of "from" cell. If there is a column named "id", it will be "id" from `to`, i.e,. specific pair distances. All other columns will be included in the return value of the function. `fromX` Numeric vector of x coordinates for 'from' points `toX` Numeric vector of x coordinates for 'to' points `fromY` Numeric vector of y coordinates for 'from' points `toY` Numeric vector of y coordinates for 'to' points `maxDistance` Numeric scalar. The maximum distance cutoff for returned distances. `angles` Logical. If `TRUE`, then the function will return angles in radians, as well as distances.

## Details

A slightly faster way to calculate distances.

## Value

`pointDistance2`: a matrix with all the `to` columns plus one extra `dists` column. `pointDistance3`: a matrix with `x` and `y` columns from `to` plus one extra `dists` column.

A matrix with 3 columns, x0, y0 and dists.

SpaDES.tools documentation built on July 15, 2018, 9:01 a.m.