VisExercises

Exercise 5

Exercise 4 | | Exercise 6

Plotting with OpenGL

Exercise (5a)

  • Model a table with 4 legs using Blender.
  • Export the model as .obj, and load and render the model in the qlglwindow.cpp module.

Exercise (5b)

  • Draw a scene graph that represents two tables with 4 legs (sketch the graph on paper!).
  • Transform the graph into OpenGL commands (on paper).

Exercise (5c)

  • Use the Qt frame work to render a table with OpenGL as follows:
    • Modify the qlglwindow.cpp module and draw a single table using lglBegin(…) etc. commands.
    • Use a white quad (LGL_QUAD) for the table top and brown lines (LGL_LINES) for the four legs.
  • Draw two tables using the matrix stack.
  • Optional: Draw 10+ rotating tables.

Exercise (5d)

  • Extend the framework to draw a spiral $\vec{p}(\lambda)$ with OpenGL.
    • $\vec{p}(\lambda) = (cos\pi\lambda,sin\pi\lambda,\frac13)^T\frac1{\lambda}, \lambda\in[1,10]$
    • Use the vec3 class of the glVertex frame work to represent points in 3D space.
    • Implement a function $f(\lambda)$ that calculates and returns one 3D point on the parametric curve.
    • Use line segments to represent the spiral → lglBegin(GL_LINE_STRIP).
    • Color the spiral from red to blue.
    • Let the spiral rotate.
  • Optional: Draw the three axis of the local coordinate system of the spiral.
  • Optional: Let the viewer oscillate up and down (using the sine function). Keep the center of the spiral in focus.
  • Optional: Draw multiple rotating and colored spirals.

Home work (5e)

  • Given the function $f(x,y)=x^2e^{-x^2}y^2e^{-y^2}$
    • Use gnuplot to plot the function
set isosample 30
splot [-3:3][-3:3] x*x*exp(-x*x)*y*y*exp(-y*y)
Gnuplot
  • Plot the function with OpenGL in [−3,3]x[−3,3] with a grid of 30 by 30 lines.
    • Exaggerate the heights.

Home work (5f)

  • Plot the function with OpenGL using solid quadrilaterals (quads).
    • Map the function values to gray scale from black (lowest) to white (highest).
    • Print a screen shot of the 3D plot.


Exercise 4 | | Exercise 6

Options: