In this assignment, we used computer programming in Processing to write algorithms and procedures with turtle geometry and L-systems to generate creative designs.


Part 1 – simple composite image

for this first part, we used simple processing functions to make a series of points, circles, triangles, and rectangles.

Part 2 – turtle library

For the next part, we were tasked with making geometries using the turtle library.

we first drew the capital letter I and T.

We then drew a triangle.

Then, we made a regular pentagon.

We then drew a circle. For this I used the formula [(k-2)/k]*180, where k is the number of sides, to determine the internal angle of a circle with 100 sides, then I drew it like I did the pentagon.

Part 3- L-Systems

we next had to make our own L-Systems. Using the stater code that was provided, I filled in the missing code so the basic square L-System would work.

Square L-system on iteration 4
L-System 1

For my first L-system, I wanted to make a pattern that looked like a branch of a tree. To figure out what I wanted the original branch to look like I drew it out on paper and marked where I would need to pop and push.

Vocabulary: “F”

Axiom: “F”

Production Rules:

‘F’ -> “FF[F[]-F[F]+F]+”

‘[‘ -> “[“

‘]’ -> “]”

‘+’ -> “+”

‘-‘ -> “-“

Iteration Strings:

n=0: “F”

n=1: “FF[F[]-F[F]+F]+”

n=2: “FF[F[]-F[F]+F]+FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+[]-FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+]+FF[F[]-F[F]+F]+]+”

n=3: “FF[F[]-F[F]+F]+FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+[]-FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+]+FF[F[]-F[F]+F]+]+FF[F[]-F[F]+F]+FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+[]-FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+]+FF[F[]-F[F]+F]+]+[FF[F[]-F[F]+F]+FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+[]-FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+]+FF[F[]-F[F]+F]+]+[]-FF[F[]-F[F]+F]+FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+[]-FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+]+FF[F[]-F[F]+F]+]+[FF[F[]-F[F]+F]+FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+[]-FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+]+FF[F[]-F[F]+F]+]+]+FF[F[]-F[F]+F]+FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+[]-FF[F[]-F[F]+F]+[FF[F[]-F[F]+F]+]+FF[F[]-F[F]+F]+]+]+”

L-System 2

My next L-system was also branch looking, but this time it was more lightning bolt like. To make this I just played around with different sequences of forwards and rotations and pushing and popping.

Vocabulary: “F”

Axiom: “F+F+F”

Production Rules:

‘F’ -> “+F+F–F[F+F]”

‘[‘ -> “[“

‘]’ -> “]”

‘+’ -> “+”

‘-‘ -> “-“

Iteration Strings:

n = 0: “F+F+F”

n = 1: “+F+F–F[F+F]++F+F–F[F+F]++F+F–F[F+F]”

n=2: “++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]”

n=3: “+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]–++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]][++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]]++++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]–++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]][++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]]++++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]–++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]][++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]+++F+F–F[F+F]++F+F–F[F+F]–+F+F–F[F+F][+F+F–F[F+F]++F+F–F[F+F]]]”

L-System 3

For my last L system, I created a more geometric design based on the start of a pentagram. This one didn’t have any pushing or popping.

Vocabulary: “F”

Axiom: “F+F+F+F+F”

Production Rules:

‘F’ -> “-F-F-F+F”

‘+’ -> “+”

‘-‘ -> “-“

Iteration Strings:

n = 0: “F+F+F+F+F”

n = 1: “+F+F–F[F+F]++F+F–F[F+F]++F+F–F[F+F]”

n=2: “–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F”

n=3: “—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F—F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F+–F-F-F+F–F-F-F+F–F-F-F+F+-F-F-F+F”

part 4 – Random and Probabilistic L-Systems

For the extra credit, we were tasked with creating an l-system that would have random distances and angles on each iteration, so that the code out output a different image each time. After making a new file, I added 2 lines of code to make those random numbers. I also changed the Lsystem to be a ProbabilisticLSystem in the ExampleLsystems file, the class type in the ProbabilisticLSystem file, and in the initialization in the LSystemsBase file.

Vocabulary: “F”

Axiom: “F-F+F++”

Rules:

‘F’ -> “-F-F-F+F”

‘+’ -> “+”

‘-‘ -> “-“

iterations 1-3 of the first output

iterations 1-3 of the second output

Iterations 1-3 of the third output

for the second part of extra credit, along with random distances and random angles, we also had to make random rules. Here’s what I did:

I made a string array of a couple rules that my LSystem could use, and then placed them all. in the rules hash table. I then used my random number and assigned different rules based on what the random number gave me.

Vocabulary: “F” and “G”

Axiom: “F+F+G—F”

Rules:

‘F’ -> “+F+FF–F”

‘F’ -> “-[F+]F++F-F”

‘F’ -> “FFF++F–F–F”

‘F’ -> “–[F+F]++F”

‘G’ -> “F++G-G[+F]”

‘+’ -> “+”

‘-‘ -> “-“

‘[‘ -> “[“

‘]’ -> “]”

Iterations 1-3 of first output

iterations 1-3 of the second output

iteration 1-3 of the third output

Leave a comment