Drawing Amoebae Part 2

Now that we have points which move in an amoeba-like pattern we need to be able to draw a smooth and continuous curve through these points so that our amoeba's outline looks realistic. To do this we will use the built in quadratic curve primitives provided by java. A quadratic curve takes three points. A beginning point, an end point, and a control point which will cause the curve to be stretched in its direction. It works exactly the same way as the curved line tool in MS Paint.


For the amoeba, these beginning and end points will not be the nodes themselves, but rather the midpoints between each node. Then we will use each node as a control point stretching the line between each midpoint to it's left and right. In the following picture, nodes are the large circles and midpoints are the small circles.


You can see that the cubic curves become continuous when you use midpoints as the beginning and end points. Using this approach we obtained a very good looking amoeba outline.

Drawing Amoebae Part 1


We've just started working on a simple Android game related to "the cell." We only have a vague idea, at this point, of what the general premise of the game is, but one of the graphics requirements is the ability to draw a dynamically moving and undulating amoeba with smooth graphics. So this is how we went about doing it.



To start, the outline of the amoeba consists of 20 or so evenly spaced nodes shaped as a circle. Here we will only show a few for simplicity. To get the locations for x number of nodes around a circle we use basic trigonometry.
increment = 2PI / numPoints;
For each point calculate the angle:
theta = i * increment;
To get the x and y locations from this angle use:
x = radius * cos(theta);
y = radius * sin(theta);




In order to keep the amoeba at a generally-similar size and shape it will be bound by somewhat of an exoskeleton. So at each of the previously calculated locations we create a node representing a piece of the exoskeleton which will not move or be visible (dotted) and an actual node mass which moves and makes up the shape of the amoeba (solid). These nodes are assigned random momenta so they start of moving in random directions.






If we just let the masses move off in their random directions decided in the previous step this wouldn't look like an amoeba at all. We now need to make the the amoeba undulate. We do this by simulating the physics which would happen if there were a spring between each node and a strong spring between each node and its corresponding exoskeleton point. This will keep all of the nodes close together so they are similar to the original circular shape, but allow them to undulate forming the basic outline of a moving amoeba.




Putting all of these steps together we get a very amoeba-like set of ~20 points, which undulates to varying degrees depending on the various constants we set. We are able to modify the spring constants, the masses of the nodes, and the number of nodes in order to experiment with various effects. Here is the result of our first few steps: