Learn R Programming

trajr (version 1.5.1)

TrajScale: Scale a trajectory

Description

Scales the cartesian coordinates in a trajectory, for example, to convert units from pixels to metres.

Usage

TrajScale(trj, scale, units, yScale = scale)

Value

new scaled trajectory.

Arguments

trj

The trajectory to be scaled.

scale

Scaling factor to be applied to the trajectory coordinates.

units

Character specifying the spatial units after scaling, e.g. "m" or "metres"

yScale

Optional scaling factor to be applied to the y-axis, which may be specified if the original coordinates are not square. Defaults to scale.

Examples

Run this code
set.seed(42)
trj <- TrajGenerate()
# original trajectory units are pixels, measured as having
# 47 pixels in 10 mm, so to convert to metres, scale the
# trajectory by the approriate factor, i.e. (size in metres) / (size in pixels).
scale <- .01 / 47
scaled <- TrajScale(trj, scale, "m")

Run the code above in your browser using DataLab