Rotating perspectives

generative-art
R
Author
Affiliation

Massachusetts Institute of Technology

Published

January 3, 2021

I have been asked to unveil a bit of what’s under the hood on this post. I decided to make a new post to share how my creative process took place and maybe inspire others to play along.

Something interesting about all of this is how well it plays into common sense. Looking at things from a different perspective, in this case adding just a rotation, can yield outstanding results.

The shapes

First of all, we are going to use the shapes provided by ggforce::geom_regon().

Code
library(tidyverse)
library(ggforce)

df <- data.frame(
  x0=3:8,
  y0=1,
  r=0.2
)

ggplot(df)+
  geom_regon(aes(x0 = x0, y0 = y0,
                 r = r, sides= x0, angle = 0),
             fill="gray50", color="black")+
  coord_equal()+
  labs(title="Regular polygons using ggforce", 
       x="", y="",
       caption="@NeuroMLA")+
  theme(panel.background = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank(),
        plot.title = element_text(hjust=0.5))

The twist

Now we can implement a rotation to each figure. We will use the previous df and expand_grid() to add an angle rotation to the regular polygon. The greater the number of sides, the closer we get to a circular shape illusion when we rotate and overlap the polygons. For n>6 it didn’t generate the type of look I was looking after during my experimentation.

Code
df <- expand_grid(df, angle = seq(0, 0.5, 0.1))

 
ggplot(df)+
  # notice we use angle = angle now
  geom_regon(aes(x0=x0,y0=y0,r=r, sides=x0, angle=angle),
             fill="gray50", color="black")+
  coord_equal()+
  labs(title="Rotated regular polygons using ggforce", 
       x="", y="",
       caption="@NeuroMLA")+
  theme(panel.background = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank(), 
        plot.title = element_text(hjust=0.5))

We can tinker with the alpha and fill to make some nice looking shapes. I’m not going to modify color but it’s also a possibility.

Code
ggplot(df)+
  # notice we use angle = angle now and fil=factor(x0)
  geom_regon(aes(x0=x0,y0=y0,r=r, sides=x0, angle=angle,
                 fill=factor(x0)), 
             alpha=0.1, color="black")+
  coord_equal()+
  labs(title="Rotated regular polygons using ggforce", 
       x="", y="",
       caption="@NeuroMLA")+
  theme(panel.background = element_blank(),
        legend.position = "none",
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank(),
        plot.title = element_text(hjust=0.5)) -> p

print(p)

Make it pallette

We can have unlimited color combinations. Just as a start, two places I like to use when dealing with color pallettes in R:

We will use scale_fill_*() functions of ggplot. I normally use scale_fill_manual() if I want to handpick the values, but scale_fill_viridis() and scale_fill_brewer() often do a nice job too!

Reuse

Citation

BibTeX citation:
@online{andina2021,
  author = {Andina, Matias},
  title = {Rotating Perspectives},
  date = {2021-01-03},
  url = {https://matiasandina.com/posts/2021-01-03-rotating-perspectives},
  langid = {en}
}
For attribution, please cite this work as:
Andina, Matias. 2021. “Rotating Perspectives.” January 3, 2021. https://matiasandina.com/posts/2021-01-03-rotating-perspectives.

Enjoy my creations?

I'm so glad you're here. As you know, I create a blend of fiction, non-fiction, open-source software, and generative art - all of which I provide for free.

Creating quality content takes a lot of time and effort, and your support would mean the world to me. It would empower me to continue sharing my work and keep everything accessible for everyone.

How can you support my work?

There easy ways to contribute. You can buy me coffee, become a patron on Patreon, or make a donation via PayPal. Every bit helps to keep the creative juices flowing.



Become a Patron!

Share the Love

Not in a position to contribute financially? No problem! Sharing my work with others also goes a long way. You can use the following links to share this post on your social media.

Affiliate Links

Please note that some of the links above might be affiliate links. At no additional cost to you, I will earn a commission if you decide to make a purchase.


© CC-By Matias Andina, 2023 | This page is built with ❤️ and Quarto.