# distfun

##### Distance Map as a Function

Compute the distance function of an object, and return it as a function.

##### Usage

```
distfun(X, ...)
## S3 method for class 'ppp':
distfun(X, ...)
## S3 method for class 'psp':
distfun(X, ...)
## S3 method for class 'owin':
distfun(X, ..., invert=FALSE)
```

##### Arguments

- X
- Any suitable dataset representing a two-dimensional
object, such as a point pattern (object of class
`"ppp"`

), a window (object of class`"owin"`

) or a line segment pattern (object of class`"psp"`

). - ...
- Extra arguments are ignored.
- invert
- If
`TRUE`

, compute the distance transform of the complement of`X`

.

##### Details

The `f(x,y)`

is the shortest distance from $(x,y)$ to $A$.

The command `f <- distfun(X)`

returns a *function*
in the Rlanguage, with arguments `x,y`

, that represents the
distance function of `X`

. Evaluating the function `f`

in the form `v <- f(x,y)`

, where `x`

and `y`

are any numeric vectors of equal length containing coordinates of
spatial locations, yields the values of the distance function at these
locations.

This should be contrasted with the related command `distmap`

which computes the distance function of `X`

on a grid of locations, and returns the distance
values in the form of a pixel image.

##### Value

- A
`function`

with arguments`x,y`

. The function also belongs to the class`"distfun"`

for which there is a print method and a plot method.

##### See Also

##### Examples

```
data(letterR)
f <- distfun(letterR)
f(0.2, 0.3)
```

*Documentation reproduced from package spatstat, version 1.17-1, License: GPL (>= 2)*