Brandon Roots
  • INTERACTIVE
  • FILM
  • ABOUT
  • CONTACT
February 28, 2021

Oscillation

broots ITP, Nature of Code

For this week’s assignment in The Nature of Code I used what we have learned about generating oscillations with trigonometric functions to create an abstract clock. My goal was to create something that shows the passage of time in an interesting, though not necessarily useful, way.

This clock sketch makes use of the millis() function to visualize minutes, hours, and days up to a year from the start of the sketch in concentric rings around an oscillating pair of lights in the middle representing seconds.

While I hoped to create something beautiful and meditative the final design ultimately gives me a headache. It did help me though to better understand using sin() to animate oscillations and movement around circles.

let minR = 50;
let hrR = 100;
let dayR = 150;
let yearR = 200;

function setup() {
  createCanvas(windowWidth, windowHeight, WEBGL);
}

function draw() {
  background(0);
  noStroke();
  
  
  // background light with second oscilation
  
  let lightX = sin((millis()/240)%TWO_PI);
  
  pointLight(5, 125, 245, lightX*10, 0, 50);
  pointLight(245, 125, 5, -lightX*10, 0, 50);
  plane(windowWidth, windowHeight);

  let incrementMinute = map((millis()/120)%500, 0, 500, PI, 0.01);
  let incrementHour = map((millis()/7200)%500, 0, 500, PI, 0.01);
  let incrementDay = map((millis()/172800)%500, 0, 500, PI, 0.01);
  let incrementYear = map((millis()/6307200)%500, 0, 500, PI, 0.01);
  
  translate(0, 0, 50);
  fill(200);
  
  // year counter
  for(let i = 0; i < TWO_PI; i+= incrementYear){
    let x = yearR * sin(i);
    let y = yearR * cos(i);
    fill(250);
    circle(x, y, 12)
  }
  
  // day counter
  for(let i = 0; i < TWO_PI; i+= incrementDay){
    let x = dayR * sin(i);
    let y = dayR * cos(i);
    fill(250);
    circle(x, y, 9)
  }
  
  // hour counter
  for(let i = 0; i < TWO_PI; i+= incrementHour){
    let x = hrR * sin(i);
    let y = hrR * cos(i);
    fill(250);
    circle(x, y, 6)
  }
  
  // minute counter
  for(let i = 0; i < TWO_PI; i+= incrementMinute){
    let x = minR * sin(i);
    let y = minR * cos(i);
    fill(250);
    circle(x, y, 3)
  }
  
}
Forces Kinetic and Measurement Project Updates

Related Posts

Fractal Plant – Foiled by  Registers

Homemade Hardware, ITP, Solar Plant

Fractal Plant – Foiled by Registers

Since receiving the PCBs and successfully soldering the board together I have been trying to rewrite code for the I2C port expander. This has been immensely difficult! The Inkplate Arduino Library makes considerable use of an “Mcp” class, which is written to work with the MCP23017 GPIO expander IC. These chips are quite difficult to […]

“Handling” Playtest Week

Handling, ITP

“Handling” Playtest Week

Last week we attended “Playtest Thursday” on the second floor of 370 Jay St with our games. I came away from the experience with some very specific feedback. Seeing a number of people play the game showed me things I didn’t anticipate. Some folks approached the cabinet and immediately treated it as a touch screen. […]

Fractal Plant – Beta Build

Homemade Hardware, ITP, Solar Plant

Fractal Plant – Beta Build

The boards arrived! Amazingly within an hour of one another. Based on the experience I think that JLCPCB is a better value. With shipping OSHPark was $55.50 for 3 boards. JLCPCB was $26.36 for 10 boards. Aside from a higher cost OSHPark also left sharp bits of tabs around the edges of the boards which […]

Recent Posts

  • Fractal Plant – Foiled by  RegistersFractal Plant – Foiled by Registers
    May 9, 2022
  • “Handling” Playtest Week“Handling” Playtest Week
    May 5, 2022
  • Fractal Plant – Beta BuildFractal Plant – Beta Build
    April 24, 2022
Brandon Roots