Beautiful functions
The first task for our current mission is to create a 2D shape that can be used as a cross section for a vase. We will use polar coordinates to create a circular shape and a function that alters the radius based on the rotational angle to make it look more interesting.
We will also add a GUI using the controlP5 library by Andreas Schlegel to enable the users of our sketch to modify the curve.
Engage Thrusters
Let's start drawing curves:
Start a new Processing sketch and add the
setup()
anddraw()
methods.void setup() { } void draw() { }
Now add two float arrays that will hold the vertex coordinates of our shape. Also add the initialization code to your
setup()
method. We will use a vertex every 5 degrees, so we need 72 vertices for our shape.float vertx[]; float verty[]; void setup() { size(400,400); vertx = new float[72]; verty = new float[72]; }
To create the values for our coordinates, we add two methods; one that calculates the radius of our polar coordinates for...