Rotate x,y coordinates by an arbitrary amount of degrees

rotate_coords(xy, degrees)

Arguments

xy

(x,y) coordinates

degrees

Numeric; angle to rotate (x,y)

Examples

#load data
data(wings)

shapes <- wings$shapes
links <- wings$links

# rotate first shape from the data set
rot_shape <- rotate_coords(shapes[,,1], 180)

#plot and compare
plot(shapes[,,1], pch = 1)
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Error in plot.window(...): need finite 'xlim' values

Morpho::lineplot(shapes[,,1], links)
#> Error in if (dim(x)[2] == 3) {    if (is.list(point) == TRUE) {        for (i in 1:length(point)) {            lines3d(x[point[[i]], 1], x[point[[i]], 2], x[point[[i]],                 3], col = col, lwd = lwd, line_antialias = line_antialias)        }    }    else {        lines3d(x[point, 1], x[point, 2], x[point, 3], col = col,             lwd = lwd, line_antialias = line_antialias)    }} else {    if (!add) {        plot(x, asp = 1, cex = 0, xlab = "x-coordinate", ylab = "y-coordinate")    }    if (is.list(point) == TRUE) {        for (i in 1:length(point)) {            lines(x[point[[i]], 1], x[point[[i]], 2], col = col,                 lwd = lwd, lty = lty)        }    }    else {        lines(x[point, 1], x[point, 2], col = col, lwd = lwd,             lty = lty)    }}: argument is of length zero

points(rot_shape, pch = 16, col = "red")
Morpho::lineplot(rot_shape, links, col = "red")
#> Error in x[point, 1]: subscript out of bounds