The recipe is as follows:
- Pick random points on a 2D grid
- Find the 'convex hull' of the points.
- Pick an interior point, and connect it to a random edge, as long as it does not intersect another edge
- Repeat #3 until all points are assigned.
There are a number of criteria described implicitly or explicitly by A&A about whether a shape should be legitimate. Things like 'do lines cross' is trivial for a research assistant to identify when doing this by hand on graph paper, but not exactly trivial when doing this algorithmically. A MATLAB routine for constructing these shapes was published more recently by Collin & McCullen (2002), and they worked through many of these issues. I have borrowed heavily from their examples, and come up with a MakeAttneave() function that creates points for an Attneave shape that satisfies a number of criteria.
MakeAttneave is called with the following arguments:
MakeAttneave works by first finding the convex hull, just like the recipe above. As a side effect, we now have a ConvexHull function available in PEBL, which can be useful for other purposes. After the convex hull is found, we just take the remaining shapes, and try to add them in random positions in the current shape, one at a time. At each point, we pick a random edge, and then create candidate edges between the two endpoint of that edge and the new point. Then, check to see if the new edges cross any other edges, and whether the angles are valid. It should always be possible to find a pair of points between which you can fit any interior point, but sometimes it won't be possible to find one that doesn't violate the edge constraints. When this happens, I have an 'emergency out: I simply call the MakeAttneave function recursively. In its current form, I don't do any checks, so it is possible to create constraints that make it impossible to find a legal figure, and the function will recurse until its stack depth or the machine memory runs out, and the system crashes. So take care when you use it.
What does the output look like? First, let me try two sets with fairly high minimum angles (20 degrees):
Lets decrease the minimum angle from 20 degrees to 5, for each number of points:
These didn't take as long to make, which is nice, but you get those spikes, which may not be ideal.
Trying to push the parameters further leads to some problems. With 10 points, you can set the minimum angle as high as 50 degrees, without the search taking too extremely long. And it creates nice full polygons.
10 points, 50-175 degrees
Don't try doing this with 20-point polygons. With 20 points, there just aren't good ways to connect all the points without having a few very small angles, and it rarely finds a legal polygon. And even without raising the lower angle limit, as you add more points, legal polygons become difficult to find. I can create 25-sided polygons if I set the lower limit to 1 degree, but larger than that gets very slow and difficult to find solutions for. For polygons this large, there may be other approaches that are better than this one--you might just want to find an approximate solution for the traveling salesman problem on the points (as described in the trail-making task) and then check for overlapping edges, and ignore angle restrictions. Here is a set of 25-sided and 30-sided Attneave shapes:
30 points, .1-179 degrees
These get quit complex, and start filling in more of the circle-mashing together to fit enough vertices in the constrained shape. They share a resemblance even if they aren't similar in shape. In the future, when I blog about the object judgment task, I'll describe how to create (and validate) shape families--shapes that have a family resemblance, yet are still valid according to the testing criteria.
Attneave, F., & Arnoult, M. D. (1956). The quantitative study of shape and pattern perception. Psychological Bulletin, 53(6), 452-471.
Collin, C. A., & Mcmullen, P. A. (2002). Using Matlab to generate families of similar Attneave shapes. Behavior Research Methods Instruments and Computers, 34(1), 55-68.