Learn R Programming

geometr (version 0.2.5)

gt_reflect: Reflect geoms

Description

Reflect geoms across a reflection axis.

Usage

gt_reflect(geom = NULL, angle = NULL, fid = NULL, update = TRUE)

Arguments

geom

[geom(.)] the object to reflect.

angle

[numeric(1)] the counter-clockwise angle by which the reflection axis shall be rotated (can be negative to rotate clockwise).

fid

[integerish(.)] if only a subset of features shall be rotated, specify that here.

update

[logical(1)] whether or not to update the window slot after rotation.

Value

Reflected geom.

Details

The reflection axis is a straight line that goes through the plot origin with the given angle, where positive angles open towards the positive y-axis and negative angles open up towards the negative y-axis.

See Also

Other geometry tools: gt_rotate(), gt_scale(), gt_sketch(), gt_skew(), gt_stretch(), gt_translate()

Examples

Run this code
# NOT RUN {
# the original object
coords <- data.frame(x = c(30, 60, 60, 40, 10, 40, 20),
                     y = c(40, 40, 60, 70, 10, 20, 40),
                     fid = c(1, 1, 1, 1, 2, 2, 2))
window <- data.frame(x = c(-80, 80),
                     y = c(-80, 80))
aGeom <- gs_polygon(anchor = coords, window = window)

# reflect several geoms
visualise(geom = gt_reflect(geom = aGeom, angle = 30))

# reflect a single geom
visualise(geom = gt_reflect(geom = aGeom, angle = -45, fid = 1))
# }

Run the code above in your browser using DataLab