Difference between revisions of "Branch Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 2: Line 2:
 
[[File:Dragon trees.jpg|thumb]]
 
[[File:Dragon trees.jpg|thumb]]
  
 +
=Code to Investigate=
 +
<nowiki>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</nowiki>
  
 
=Code to Implement=
 
=Code to Implement=
==Turtle==
 
 
 
==OpenGLStackUtils==
 
==OpenGLStackUtils==
 
  <nowiki>class OpenGLStackUtils
 
  <nowiki>class OpenGLStackUtils

Revision as of 08:26, 24 November 2020

Lindenmayer system

Dragon trees.jpg

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<nowiki>

==Branch==
 <nowiki>class Branch
  def branch(length, line_width_in_pixels, depth_remaining)
    raise :not_yet_implemented
  end
end
Branch MaxDepth0.png Branch MaxDepth1.png Branch MaxDepth2.png Branch MaxDepth3.png [[File:Branch_MaxDepth4.png] Branch MaxDepth5.png
max_depth: 0 max_depth: 1 max_depth: 2 max_depth: 3 max_depth: 4 max_depth: 5