library(ggplot2)
original_square <- data.frame(
x = c(0, 3, 3, 0, 0),
y = c(0, 0, 3, 3, 0)
)
rotated_square <- rotator(data = original_square,
x = x,
y = y,
angle = 45,
anchor = "center")
ggplot()+
geom_path(data = original_square,
aes(x,y),
color = "red")+
geom_polygon(data = rotated_square,
aes(x,y),
fill = "purple")+
coord_equal()
Run the code above in your browser using DataLab