Part A, specifying problems 1 and 2 along with rules and objectives, is in a separate document.
When you look at the figure to the right, do the diagonal lines look like they run continuously under the yellow bars, or does each column look staggered? And are the yellow bars themselves perfectly vertical, or are they slanted down and to the right? These effects are known as the Poggendorff illusion and were first reported in 1860. Your job is to reproduce the illusion using Matlab graphics. But rather than specializing to a single “instance” of the illusion, your code will be parameterized, allowing users to customize the slope and spacing of the lines in order to study their effect on what we perceive.
We have chosen to parameterize the illusion in the following way:
While these parameters completely specify an instance of the illusion, they are not the most convenient to work with when actually drawing the shapes involved. Therefore, we recommend you first compute several derived parameters based on their values. A recommended set are shown in the figure below. You may find the following relation to be useful: dx=k·dy/slope.
Write a script, Poggendorff, that draws the Poggendorff illusion in Matlab’s figure window according to the above parameters. The parameters must be declared as variables at the top of the script, and changing a parameter should only require changing the corresponding variable initialization (that is, you should not hard-code assumed parameter values in your drawing routines; only use the variable names).
Use the plot()
function to draw each line in each column (refer to Project 1); you may choose their color. You should draw k-1 lines starting below the figure in addition to the numLines lines that start within the figure (not all of them will extend into the region of interest; that’s okay—in our example, only one of these two extra lines is visible). Your lines may extend above and below the final figure, but they must not extend underneath any of the vertical rectangles. Use hold on
to allow the lines to “stack up” in the same figure window, and use axis equal off
to keep the figure clean and preserve geometry (see Lecture 6). Use axis()
to restrict (“crop”) the figure to the desired width and height, hiding anything that extended outside of that region. Use FillRect()
from the course website to draw the vertical rectangles in a color of your choosing.
Note: you will not know how many columns to draw until after you have computed dx; the ceil()
function may be useful for this purpose (and remember, for this problem, you are allowed to draw outside of the final axis range).
Parameterization is an important concept in engineering design as well as in computation. A good choice of parameters allows the end result to adapt self-consistently when a single parameter is varied, rather than having to re-tune the entire design by hand. This makes it easier to experiment with different design variations, and it also makes your code more robust and maintainable. Consequently, often your first task when tackling a problem computationally should be to identify a good set of parameters.
A parameterized solution requires more testing than a one-off solution, however. After you have written some code for this assignment, be sure to test it with a variety of different parameter values to ensure that the result scales appropriately. Can you reproduce the figure in this document? What choice of parameters makes the illusion strongest for you? Your submission should use these personalized parameter values.
Submit your file Poggendorff.m on CMS (after registering your group), in addition to your files for Part A.