coordinates.difference: Coordinates differences

View source: R/coordinates.difference.R

coordinates.differenceR Documentation

Coordinates differences

Description

Calculates coordinate differences (e.g. from Procrustes superimpositions)

Usage

coordinates.difference(
  coordinates,
  reference,
  type = "cartesian",
  angle = "degree",
  absolute.distance = TRUE,
  rounding = NULL
)

Arguments

coordinates

An array, list or matrix of coordinates to be compared to the reference.

reference

A matrix of reference coordinates. If missing and coordinates is an array or list, the first element of coordinates is used.

type

the type of coordinates to output: can be "cartesian" (x0, y0, x1, y1,... format), "spherical" (radius, polar, azimuth) or "vector" (length, angle(s)).

angle

optional, whether display angles in radian ("radian") or in degrees ("degree" - default).

absolute.distance

logical, when using "vector", whether to use the absolute distance (from the centroid) or the relative one (from the reference landmark). See details.

rounding

optional, a tolerance value for rounding pairs of landmarks (passed to round), if NULL (default), no rounding is applied and exact differences are calculated.

Details

When using type = "vector" with absolute.distance = TRUE, the distance between two landmarks A and A' is calculated as d(0,A') - d(0,A) where 0 is the centroid of the shape to analysis. A positive absolute distance means that A' is further away from the centroid than A. A negative absolute distance means that A' closer to the centroid than A. When using absolute.distance = FALSE, the distance is calculated as d(A,A') and is always positive.

Author(s)

Thomas Guillerme

See Also

variation.range

Examples

## Loading the geomorph dataset
require(geomorph)
data(plethodon)

## Performing the Procrustes superimposition
proc_super <- geomorph::gpagen(plethodon$land, print.progress = FALSE)

## Getting the coordinates differences from the consensus
cartesian_diff <- coordinates.difference(proc_super$coords, proc_super$consensus)

## The coordinates of the differences between the first specimen and the consensus
head(cartesian_diff[[1]])

## Getting the spherical coordinates difference between the two first specimen
coordinates.difference(proc_super$coords[, , 1], proc_super$coords[, , 2],
                       type = "spherical", angle = "degree")

## Getting the vector coordinates for the same specimen in relative distance
coordinates.difference(proc_super$coords[, , 1], proc_super$coords[, , 2],
                       type = "vector", angle = "degree", absolute.distance = FALSE)

## Getting the vector same coordinates in absolute distances
coordinates.difference(proc_super$coords[, , 1], proc_super$coords[, , 2],
                       type = "vector", angle = "degree")

TGuillerme/landvR documentation built on July 4, 2025, 10:16 p.m.