coordturn: Rotate Coordinates

Description Usage Arguments Value References See Also Examples

View source: R/coordturn.R

Description

Rotate coordinates clockwise around a pivot point.

Usage

1
coordturn(pts, pvt, rot)

Arguments

pts

A numeric matrix with two columns of x and y coordinates to be rotated.

pvt

A numeric vector of length 2, the x and y coordinates of the pivot point around which pts will be rotated.

rot

A numeric scalar indicating the amount of clockwise rotation, in radians.

Value

A numeric matrix with same dimension as pts with the rotated x and y coordinates.

References

Modification of code posted by Sage on 3 March 2011 on the website benn.org [link].

See Also

coordplot, coordmove, coordflip, coordtri.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# starting coordinates
test <- matrix(c(0, 4, 1, 0, 2, 3), ncol=2,
 dimnames=list(LETTERS[1:3], NULL))
coordplot(test)
# rotate the coordinates clockwise 45 degrees
# around the first point (the origin)
rottest <- coordturn(test, test[1, ], rot=pi/4)
coordplot(rottest)
# rotate the coordinates counterclockwise 45 degrees
# around the first point (the origin)
rottest <- coordturn(test, test[1, ], rot=-pi/4)
coordplot(rottest)

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.