Magnitude of a 3D vector

Here Simon explains how to calculate the magnitude of a 3D vector. This is something he partially figured out on his own and partially learned from Daniel Shiffman’s tutorial on Trigonometry and Polar Coordinates.

 

DSC_0540

Infinite Line in Processing. Simon’s own code.

A beautiful project in Processing (Java), Simon’s own code, resembling  an El Lissitzky painting that you can control and change with the mouse (without Simon knowing El Lissitzky). Resulted from thinking about and playing with infinite line and line segments. Simon used the following formula: slope times x plus yIntercept.

Infinite Speceship 13 Jun 2017 2

Infinite Speceship 13 Jun 2017 1

 

 

 

DSC_0410

Smart Rockets Coding Challenge translated into Processing (Java)

And here is Simon’s translation of Daniel Shiffman’s Smart Rockets Coding Challenge into Processing (Java). This challenge (originally in JavaScript) was about implementing a genetic algorithm from scratch and create “smart rockets” (based on a simulation by Jer Thorp). The rockets evolve the “best” path to a target, moving around obstacles.

Perlin Noise Combined with Sine Wave Translation into Processing

Simon translated Daniel Shiffman’s Graphing 1D Perlin Noise tutorial into Processing (Java). The project involved combining perlin noise and sine wave:

 

He also attempted to translate Perlin Noise Flow Field into Processing:

 

dsc_0152.jpg

 

DSC_0153

 

dsc_0154.jpg

Polar to Cartesian converter (Simon’s own code)

Simon built a Polar to Cartesian converter (Simon’s own code). You can enter the radius in pixels and the angle in degrees, click “convert” and you get the coordinates in x and y and a circle appears n that spot.

You are welcome to play with Simon’s converter online in CodePen at: https://codepen.io/simontiger/pen/MmdodP

Simon is also planning to make a similar converter for Spherical to Cartesian (where you would enter radius, latitude and longitude and convert those into x,y,z).

 

 

Here Simon explains the formulas to convert between Polar and Cartesian coordinates:

 

Pinball Dilemma. Simon’s own code.

Simon heard the word “pinball” and looked it up on Google (never played it himself). He then decided to write a pinball program in Processing (Java), but soon encountered a mathematical dilemma: the flippers at the bottom of the canvas (their role is to protect the ball from falling) didn’t stop rotating the way Simon wanted. This slowly unfolded into a real drama.

Here Simon explains the problem:

As his math tutor came to give Simon his regular math lesson, Simon turned to him for help and they thought to have solved the problem by applying cosine and setting it to 1. But after the teacher left Simon realized that the angular velocity of the flipper was too high for the cosine to reach 1, which would mean the flipper wouldn’t stop. Unless approximate values could be programmed, which Simon said he doubted. Simon was crying hard. We just sat there hugging after we recorded this:

Then Simon tried writing an approximate function.

I’m not sure he will come back to this unfinished project. It is all part of his learning experience and learning to apply math/ physics though.

DSC_0030

DSC_0031

Approximate cosine:

Pinball cos solution 22 Mei 2017

Approximate Function and 1D distance function:

Pinball. Approximate Function and 1D distance function 22 Mei 2017

Pendulum Force

This is a beautiful “lecture” that Simon in his pajamas, chocolate paste adorning is face, game me Friday morning. He spoke about pendulum force, a force he was about to apply in a coding project.

The other videos form the very beginning of the lecture, with Simon plays with sine and cosine and explains why location, velocity and acceleration can be vectors and can be angles:

And this is the code where pendulum force is used. It’s an example from The Nature of Code book by Daniel Shiffman, from Chapter 3 on Oscillation:

Oscillation and Drag Force: Spring Project.

Today Simon was watching Daniel Shiffman’s tutorials to learn about drag force and how to apply it when building a spring simulation in p5.js. Simon wrote the formula for drag force in Microfost Word and looked up all the variables:

Drag Force 23 Apr 2017 2

While building a spring in p5.js, Simon talks about the 3 laws of Isaac Newton:

The project is based upon Daniel Shiffman’s book The Nature of Code, specifically Chapter 3 (Oscillation). Simon spent the rest of the evening studying “simple harmonic motion”, periods and amplitudes. Here is an excerpt from Daniel Shiffman’s book:

y = sine(x)
You’ll notice that the output of the sine function is a smooth curve alternating between –1 and 1. This type of a behavior is known as oscillation, a periodic movement between two points. Plucking a guitar string, swinging a pendulum, bouncing on a pogo stick—these are all examples of oscillating motion.
This is what is known as simple harmonic motion (or, to be fancier, “the periodic sinusoidal oscillation of an object”). It’s going to be a simple program to write, but before we get into the code, let’s familiarize ourselves with some of the terminology of oscillation (and waves).
Simple harmonic motion can be expressed as any location (in our case, the x location) as a function of time, with the following two elements:
  • Amplitude: The distance from the center of motion to either extreme
  • Period: The amount of time it takes for one complete cycle of motion
Looking at the graph of sine, we can see that the amplitude is 1 and the period is TWO_PI; the output of sine never rises above 1 or below -1; and every TWO_PI radians (or 360 degrees) the wave pattern repeats.

L-Systems

What sort of literature do you fancy in the evening? Simon’s downloaded the book The Algorithmic Beauty of Plants tonight.

IMG_4465

Here Simon explained to me how L-systems and Cantor Set worked:

img_4468.jpg

IMG_4467

An L-system or Lindenmayer system is a parallel rewriting system and a type of formal grammar. An L-system consists of an alphabet of symbols that can be used to make strings, a collection of production rules that expand each symbol into some larger string of symbols, an initial “axiom” string from which to begin construction, and a mechanism for translating the generated strings into geometric structures.

Simon says that an L-sestem is “also a context-free grammar that can have infinite generations”.

IMG_4466

The Cantor set is a set of points lying on a single line segment that has a number of remarkable and deep properties.

Simon followed the book and Daniel Shiffman’s tutorial on L-Systems to create beautiful trees and other recursive patterns in

http://turtleacademy.com/playground/en

and

http://www.kevs3d.co.uk/dev/lsystems/#

L_System Fractal Trees 15 Apr 2017 1

L_System Fractal Trees 15 Apr 2017 2 square brackets around last F

L_System Fractal Trees 15 Apr 2017 2

L_System Fractal Trees 15 Apr 2017 23

L_System Fractal Trees 15 Apr 2017 4

And “what you also might need by an L-system is a String Buffer”:

String Buffer (might need by L system) 15 Apr 2017 2