VisExercises

## Exercise 6

‹ Exercise 5 | ● | Exercise 7 ›

## Contour Plotting with OpenGL

Exercise **(6a)**

- Sketch the two line segments for extracting the iso line for iso value = 0.25 for the following quad consisting of two triangles:

1 x---x 0.5 | /| | / | |/ | 0 x---x 0

- Find the intersection points (calculate on paper by assuming a unit sized quad).

Exercise **(6b)**

- Implement a function
*extract_intersection_point($\vec{x1}$, $\vec{x2}$, v)*that calculates the intersection point of the iso line with a line segment [$\vec{x1}$,$\vec{x2}$] for a given iso value $v$ according to the lecture.- The function gets two vertices (class v3d) and two scalar values (being identical to the height of the vertices) and the iso value (float) as parameter.
- It checks whether or not an intersection occurs.
- If an intersection occurs, we compute the respective intersection point p.
- If we find intersection points, we plot the corresponding line segment.
- This is equivalent to sending each intersection point that was found directly to the graphics

- Implement a function
*extract_isoline($\vec{ a }$, $\vec{ b }$, $\vec{ c }$)*that extracts the iso line of a triangle with the three corner points $\vec{ a }$, $\vec{ b }$, $\vec{ c }$ by calculating the intersection points for its three edges. - Visualize the above test case (exercise 4a) with OpenGL in 3D:
- Draw a solid quad with corner colors being mapped from function value to gray scale.
- Draw the iso line with line segments in red.
- The hidden-surface removal with the z-buffer may prevent the line to show up properly.
- In this case, slightly offset the line or the quads vertically to prevent z-fighting.

Home work **(6c)**

- Given the function $f(x,y)=cos(4\sqrt{x^2+y^2}+atan2(x,y))\frac{1}{0.5+\sqrt{x^2+y^2}}$
- What does the function look like? Guess? Verify!
- Extract the iso contour of the function for the iso value v=0.5 by using marching triangles on a 30×30 grid in the domain [−3,3]x[−3,3].
- Render the contour plot with OpenGL.
- Render a level set by extracting the iso contours of the function for the iso values v=0.1, 0.2 … 1.0.
- Print a screen shot of the level set.

‹ Exercise 5 | ● | Exercise 7 ›