Friday, March 2, 2007

Lab7 FAQ (part I)

Lab7 FAQ (part I)

Q1: A snowflake looks like a (fancy) triangle. But each smaller part is not a triangle. How do I use recursion to solve the problem?
Answer:
We do not draw a big triangle. Instead, we call the method 3 times (with different vertices as argument) to draw 3 segments of the snowflake.

Q2: What is really being executed? If we call ourselves all the way down to the littlest point, we don't really have a reason to come back up(up the call ladder) because we are just drawing small lines.
Answer:
At the bottom level of recursion, we know what to draw, so draw. For this program, we do not start drawing anything until we get to the bottom. What's the point of backing up the "call ladder"? So we can draw other small segments that make up for other parts of the snowflake. Even though the upper (non-bottom) levels of recursion do not draw anything, they actually calculate the positions and make calls to the lower level.

Q3: How would recursion work with the snowflake? How does recursion draw the lines and cuts out the old section?
Answer:
Again, there is no "cutting out" any lines here. It's unlike the spiral (or the Sierpinski Gasket) where we performs a draw at each level. For this lab, we only draw at the bottom level (base case of recursion).

Q4: I write a class called SnowflakeSegment. What should be the arguments to the constructor?
Answer:
Up to you. I have 2 suggestions for you. Choose either one or come up with your own. There is no right or wrong.
  1. SnowflakeSegment(Point p1, Point p2);
  2. SnowflakeSegment(Point p1, double length, double angle);
Both options would give sufficient information to the SnowflakeSegment on what to draw. Which one should you pick? ... whatever. You will need to calculate the points of subdivision from the arguments. It's a little work on geometry. Both options give you enough information for the calculation.
If you have more questions, post them here (be sure to put your name) or email me.

- Mock

No comments:

Contributors