calcCoordsBorders: Coordinates of a surrounding rectangle in direction of a...

View source: R/repgrid-plots.r

calcCoordsBordersR Documentation

Coordinates of a surrounding rectangle in direction of a given vector.

Description

An arbitrary numeric vector in 2D is to be extended so it will end on the borders of a surrounding rectangle of a given size. Currently the vector is supposed to start in the origin c(0,0).

Usage

calcCoordsBorders(x, y, xmax = 1, ymax = 1, cx = 0, cy = 0)

Arguments

x

numeric vector of x coordinates x coordinates.

y

numeric vector of y coordinates x coordinates.

xmax

maximal x value for surrounding rectangle (default is 1).

ymax

maximal y value for surrounding rectangle (default is 1).

cx

center of rectangle in x direction (not yet supported).

cy

center of rectangle in x direction (not yet supported).

Value

a dataframe containing the x and y coordinates for the extended vectors.

Examples

## Not run: 
calcCoordsBorders(1:10, 10:1)

x <- c(-100:0, 0:100, 100:0, 0:-100) / 10
y <- c(0:100, 100:0, -(0:100), -(100:0)) / 10
xy1 <- calcCoordsBorders(x, y)
xy2 <- calcCoordsBorders(x, y, xm = 1.2, ym = 1.2)
plot(xy2[, 1], xy2[, 2], type = "n")
segments(xy1[, 1], xy1[, 2], xy2[, 1], xy2[, 2])

## End(Not run)


markheckmann/OpenRepGrid documentation built on Feb. 22, 2024, 9:07 p.m.