Reflect geometric objects across a reflection axis.

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

Arguments

obj

[geometric object(1)]
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(.)]
in case 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

geom of the reflected obj.

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_filter(), gt_locate(), gt_pull(), gt_rotate(), gt_scale(), gt_skew(), gt_stretch(), gt_translate()

Examples

# reflect several features
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_reflect(obj = gtGeoms$polygon, angle = 45,
                      update = FALSE)
visualise(newPoly, linecol = "green", new = FALSE)


# reflect a single feature
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_reflect(obj = gtGeoms$polygon, angle = 90, fid = 2,
                      update = FALSE)
visualise(newPoly, linecol = "green", new = FALSE)