rigatoni – Iteration Exercise

We have entered the T H I R D  D I M E N S I O N

/*A lot of the code I have written was informed by both the References section of
  p5 as well Dan Shiffman's Youtube Channel, The Learning Train. The specific 
  tutorials I looked at are listed below:
  The Learning Channel 18.3
  The Learning Channel Coding Challenge #86
*/
 
let redraw = true
 
function setup() {
  createCanvas(500, 500, WEBGL);
  camera(500, -500, (height/2.0) / tan(PI*45.0 / 360), 0, 0, 0, 0, 1, 0)
  setLighting()
}
 
function draw() {
  if(redraw) {
    background(0);
    drawGrid()
    redraw=false
  } 
}
 
function mouseClicked() {
    redraw=true 
}
 
function drawGrid() {
  noStroke()
  translate(-250,0,250)
  for(x=0; x<10; x++) {
    translate(50,0,0)
    for(y=0; y<10; y++) {
      translate(0,0,-50)
      pickRandom(drawCube, drawSphere, .8)
    }
    //this is like setting a typewriter slide back to start
    translate(0,0,500)
  }
}
 
//the ratio is how likely pickRandom will choose method1 over method2
function pickRandom(method1, method2, ratio) {
  //using square roots helped reduce the weird looking "random" patterns
  if((random(1)*random(1))<(ratio*ratio)) {
    method1()
  } else {
    method2()
  }
}
 
function setLighting() {
  ambientLight(50,0,0)
  directionalLight(255,255,255, 25, 0, -25)
}
 
function drawCube() {
  ambientMaterial(255, 0, 0)
  box(43)
}
 
//Spheres also cast a point light around them so it looks better
function drawSphere() {
  ambientMaterial(0, 255, 0)
  pointLight(255, 255, 255)
  sphere(20)
}

via GIPHY

sketch

rigatoni – Reading #1

It's gratifying to see that a official time-honored document exists for engineers from all walks of life as there does for medical practitioners in the form of the Hippocratic Oath. The tenet that personally rung a chord with me is (1)

 

The Critical Engineer considers any technology depended upon to be both a challenge and a threat. The greater the dependence on a technology the greater the need to study and expose its inner workings, regardless of ownership or legal provision.

 

Up until this point in my creative and technical career I have been guilty of relying on a handful of tools well within my comfort zone to reify my creative vision, but it is becoming increasingly evident to me that this reliance on my staple technologies (Unity and Blender to name a few) is becoming a crutch to the point where I frame all my projects in terms of what these tools will allow me to accomplish, and thereby fail to do justice to my creative intent. (Incidentally when I introduced myself to the class, this is the core of what I was trying to express).

 

The engineers I respect the most, both in pop culture as well as real life, are the ones that can make the best of any situation. The engineers that raise no qualms about not knowing a certain language, pipeline or tool and invest themselves in learning said skills seem to be boundless in their creative capabilities.

 

This semester I am going to focus on what I see as being "language agnostic", I will boil down the core components of what I am learning so that I may adapt to any method of producing creative content. I noted some degree of parallel between (1) and (5), because ultimately all engineers are also users, and thus engineered by the products we use. I am going to strive to be a creative professional rather than a "Unity expert" or a "Java guru" (although the latter 2 labels would also be formidable to say the least).

chewie-IterationExercise

// Starter Code for "Embedded Iteration + Randomness"
var boolDoRefresh;
var rand;
var margin;
var side;
 
function setup() {
  createCanvas(400, 400);
  boolDoRefresh = true;
  margin = 10;
  side = (width-margin*9)/8
}
 
function draw() {
  if (boolDoRefresh) {
    background(255);
    for (var row = 0; row&lt;8; row++) {
			for (var col = 0; col&lt;8; col++) {
        drawElem(row, col);
      }
    }
    boolDoRefresh = false;
    }
  }
 
function mousePressed() {
  boolDoRefresh = true;
}
 
function drawElem(row, col) {
  var left = col*(side+margin)+margin;
  var top = row*(side+margin) + margin;
  rand = int(random(20));
  if (rand == 0) {
  	left += int(side/2);
    top += int(side/2);
    ellipse(left, top, side/2, side/2);
  }
  else rect(left, top, side, side);
}

 

chewie-reading01

"9. The Critical Engineer notes that written code expands into social and psychological realms, regulating behaviour between people and the machines they interact with. By understanding this, the Critical Engineer seeks to reconstruct user-constraints and social action through means of digital excavation."

This tenet observes that the code we write and the way it's expressed to users exist only in a theoretical space, but the experiences and ideas they create for their users have a very concrete impact on physical reality and our mind's perception of it. These are technologies that express how a person constructs an understanding of their reality. In this way, the technologies themselves have a significant impact on the way we understand reality and the decisions we make based on that understanding.

We design technologies that operate within our physical reality, consisting of 3 spacial dimensions along a single-dimensional timeline that we experience linearly. The mechanisms in our brains however, provide an understanding of reality where information is transmitted through space independent of mass or energy. In my personal reality I can make someone laugh, start a club, gain respect, or transcend the laws of physics by only touching a piece of glass with my body, all without having to exist at any specific point in physical space.

weirdie-Intersections

var boolDoRefresh;
var numlines = 12;
var length = 400;
var lines = new Array(numlines);
 
function setup() {
  createCanvas(720, 480);
  background(21, 62, 71);
  boolDoRefresh = true;
}
 
function draw() {
  if (boolDoRefresh) {
    //reset background
    background(21, 62, 71);
    stroke(24, 191, 179);
 
    //create lines
    for(var x = 0; x &lt; numlines; x++) 
    {
      var xstart = int(random(0, width)); 
      var ystart = int(random(0, height)); 
      var slope = random(0, 6.28); 
      var xend = length*cos(slope) + xstart; 
      var yend = length*sin(slope) + ystart; 
      lines[x] = [xstart, ystart, xend, yend]; 
    } 
    //check intersections 
    for(var l1 = numlines-1; l1 &gt;=0; l1--)
    {
      var l2 = l1-1;
      while(l2 &gt;= 0)
      {
        line1 = lines[l1];
        line2 = lines[l2];
        var cross = intersect(line1[0], line1[1], line1[2], line1[3], 
                              line2[0], line2[1], line2[2], line2[3]);
        if(cross != false)
        {
          fill(28, 229, 242);
          noStroke();
          ellipse(cross.x, cross.y, 20, 20);
        }
        l2--;
      }
    }
 
    //draw lines
    {
      for(x = 0; x &lt; numlines; x++)
      {
        stroke(24, 191, 179);
        line(lines[x][0], lines[x][1], lines[x][2], lines[x][3]);
      }
    }
 
    boolDoRefresh = false;
  }
}
 
// original calculation by Paul Bourke
// Implementation by Leo Bottaro
// http://paulbourke.net/geometry/pointlineplane/javascript.txt
// Determine the intersection point of two line segments
// Return FALSE if the lines don't intersect
function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
 
  // Check if none of the lines are of length 0
	if ((x1 === x2 &amp;&amp; y1 === y2) || (x3 === x4 &amp;&amp; y3 === y4)) {
		return false
	}
 
	denominator = ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1))
 
  // Lines are parallel
	if (denominator === 0) {
		return false
	}
 
	let ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denominator
	let ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denominator
 
  // is the intersection along the segments
	if (ua &lt; 0 || ua &gt; 1 || ub &lt; 0 || ub &gt; 1) {
		return false
	}
 
  // Return a object with the x and y coordinates of the intersection
	let x = x1 + ua * (x2 - x1)
	let y = y1 + ua * (y2 - y1)
 
	return {x, y};
}
 
function mousePressed() {
  boolDoRefresh = true;
}

weirdie-IterationExercise

var boolDoRefresh;
 
function setup() {
  createCanvas(400, 400);
  background(21, 62, 71);
  boolDoRefresh = true;
}
 
function draw() {
  if (boolDoRefresh) {
 
    background(21, 62, 71);
    noStroke();
 
    for (var r = 0; r &lt; 8; r++)
    {
      for (var c = 0; c &lt; 8; c++)
      {
    		var wow = int(random(0,12));
        if(wow == 0)
        {
          fill(28, 229, 242);
          ellipse(r*46+40, c*46+40, 40, 40);
        }
        else
        {
          fill(24, 191, 179);
          rect(r*46+20, c*46+20, 40, 40);
        }
      }
    }
    boolDoRefresh = false;
  }
}
 
function mousePressed() {
  boolDoRefresh = true;
}

weirdie-reading01

9. The Critical Engineer notes that written code expands into social and psychological realms, regulating behaviour between people and the machines they interact with. By understanding this, the Critical Engineer seeks to reconstruct user-constraints and social action through means of digital excavation.

This rule describes the fact that while we have a great deal of influence over the technology we create and its purpose, technology also has a great influence over our emotions and minds, and can be utilized to influence others. Technology, for better or for worse, can be created to bring about social change and to influence the minds of others, whether they are conscious of it or not. Particularly when art is combined with engineering, it can be used to move people towards a particular goal.

It was intriguing to me to imagine coding as something that can be designed to bring about social change and to have a psychological impact on "users". That not only does technology have an influence on the person using it, but that it has an influence on relationships between individuals.

One example of this which comes to mind are news apps that regularly notify users of certain headlines, filtering what it is that they're seeing to create an emotional response. Another is dating apps, which allow people to "browse" through profiles and possible partners based on algorithms that match their compatibility, which could become more and more advanced and specific.

casher-reading01

I found the first tenet of the manifesto to be the most interesting:

"The Critical Engineer considers Engineering to be the most transformative language of our time, shaping the way we move, communicate and think. It is the work of the Critical Engineer to study and exploit this language, exposing its influence."

This rule of the document explains how technology has become such a crucial part of our everyday lives that we basically depend on it. It has been intertwined so complexly into our daily rituals that it is considered a language -- and it has helped the world become more closely connected. It is a Critical Engineer's job to facilitate these interactions, discovering its intricacies and publishing them so the rest of the world can come to a greater understanding of what the future holds for us.

I think this guideline is especially interesting because it kind of relates to the main topic of my first year writing class, the ethics of human-enhancement technologies. Soon it will become normal for people to be partially bionic or extend their lifespans or edit their genes, which might constitute a complete reformation of society because these technologies are changing what it means to be human. Someday soon our thoughts could actually be read, controlled, and changed by technology.

chromsan-reading01

1. The Critical Engineer considers any technology depended upon to be both a challenge and a threat. The greater the dependence on a technology the greater the need to study and expose its inner workings, regardless of ownership or legal provision.

As we become more and more dependent on a single set of technologies, the authors of the manifesto see it as very important that we explore how the technologies are made and make clear how they work. Perhaps the most pertinent technology in the present is the internet; it has become so engrained in almost every part of our lives and very few people know how it really works. The same principle can be applied to applications of the internet, such as social media sites. These are particularly difficult in that they are closed source, so finding a way to examine them becomes more of a challenge, but this does not stop the Critical Engineer. When social platforms become such a huge part of people's lives, it seems important to really understand the mechanics of the system in an effort to better understand why they can so easily capture and maintain their hold on a user.

chromsan-Intersections

let refresh = true, num_lines = 12, lines = [], line_length = 300;
 
function setup() { createCanvas(720, 480) }
 
function draw() {
 
  if (refresh) {
    refresh = false;
    lines = [], clear(); background(237, 243, 255); 
 
    // generate lines 
    for (let x = 0; x &lt;= num_lines; x++) {
 
        let l = {};
        l.x1 = random(width); l.y1 = random(height); 
        // create random second point on a circle 
        let angle = random() * Math.PI * 2;
        l.x2 = (Math.cos(angle) * line_length) + l.x1
        l.y2 = (Math.sin(angle) * line_length) + l.y1;
        lines.push(l);
    }
 
    fill(140, 184, 255); noStroke();
 
    // check lines for intersection
    for (let x = 0; x &lt;= num_lines; x++) {
        for (let y = 0; y &lt; num_lines; y++) {
 
            if (y != x){
                let res = intersects(lines[x], lines[y]);
                if (res != false) ellipse(res.x, res.y, 20, 20);
            }
        }
    }
 
    stroke(0); strokeWeight(2);
 
    // draw lines 
    for (let x = 0; x &lt;= num_lines; x++) {
        line(lines[x].x1, lines[x].y1, lines[x].x2, lines[x].y2);
    }
 
  }
}
 
function mousePressed() { refresh = true }
 
// algorithm from Paul Bourke http://paulbourke.net/geometry/pointlineplane/
// adapted from Leo Bottaro's implementation
// calculate intersection point of two lines
function intersects(l1, l2) {
 
    let denom = ((l2.y2 - l2.y1) * (l1.x2 - l1.x1) - (l2.x2 - l2.x1) * (l1.y2 - l1.y1));
 
    let ua = ((l2.x2 - l2.x1) * (l1.y1 - l2.y1) - (l2.y2 - l2.y1) * (l1.x1 - l2.x1)) / denom;
    let ub = ((l1.x2 - l1.x1) * (l1.y1 - l2.y1) - (l1.y2 - l1.y1) * (l1.x1 - l2.x1)) / denom;
 
    if (ua &lt; 0 || ua &gt; 1 || ub &lt; 0 || ub &gt; 1) return false;
 
    let x = l1.x1 + ua * (l1.x2 - l1.x1);
    let y = l1.y1 + ua * (l1.y2 - l1.y1);
 
    return {x, y};
}