Difference between revisions of "Branch Assignment"
Jump to navigation
Jump to search
(→Branch) |
(→Branch) |
||
Line 45: | Line 45: | ||
next_line_width_in_pixels = line_width_in_pixels * 0.8</nowiki> | next_line_width_in_pixels = line_width_in_pixels * 0.8</nowiki> | ||
− | + | Note: the child branches are 1.0/3.0 from the beginning and the end. | |
+ | |||
+ | Note: the child branches are rotated 30.0 degrees and -30.0 degrees. | ||
+ | |||
+ | Note: in the recursive case the child branches were drawn before the line at the current depth to allow the green to be beneath the brown. | ||
{| class="wikitable" style="text-align: center; " | {| class="wikitable" style="text-align: center; " |
Revision as of 07:54, 30 November 2020
Code to Investigate
class Turtle def self.set_color(color) glColor3f(color.red, color.green, color.blue) end def self.draw_line(length, width_in_pixels) glLineWidth(width_in_pixels) glBegin(GL_LINES) glVertex2d(0.0, 0.0) glVertex2d(length, 0.0) glEnd() end def self.move_forward(magnitude) glTranslatef(magnitude, 0.0, 0.0) end def self.turn(theta) glRotatef(theta, 0.0, 0.0, 1.0) end end
Code to Implement
OpenGLStackUtils
class OpenGLStackUtils def self.push_do_pop raise :not_yet_implemented end end
Branch
class Branch def branch(length, line_width_in_pixels, depth_remaining) raise :not_yet_implemented end end
Note: to produce the reference images the code below was used:
next_length = length * 0.5 next_line_width_in_pixels = line_width_in_pixels * 0.8
Note: the child branches are 1.0/3.0 from the beginning and the end.
Note: the child branches are rotated 30.0 degrees and -30.0 degrees.
Note: in the recursive case the child branches were drawn before the line at the current depth to allow the green to be beneath the brown.
max_depth: 0 | max_depth: 1 | max_depth: 2 | max_depth: 3 | max_depth: 4 | max_depth: 5 |