This lab is an exercise in working with 3D polygon primitives.
Download file polygons.py3d. As usual, you should have a text editor and pfpy3d running side by side.
1. Find the function drawPointGrid. Here the vertex list is computed rather than written.
Have a look at how the TRS and endTRS functions are used. Try changing each of the h, p, and r parameters for the point grid.
Double the spacing between points by changing the variable. Then revert back to the original value and instead try to use the scale parameter to TRS to double the spacing.
What happens to the points themselves when scaled?
Try increasing and decreasing the point size. What is the largest point that can be drawn on your system?
2. In the "main program" section uncomment the line that invokes drawPoly. Then find that function.
Try drawing the same set of vertices as points, lines, and a polygon. Which of these will block visibility of the underlying grid?
3. In the main section, comment out drawPoly and uncomment drawPolyhedron. This is just a unit cube: py3d includes a geo.box function that could draw one for you, but here we want to manipulate the vertices directly.
Save a copy of the code somewhere so you can revert back to the original code after each following step.
Move the top four vertices of the cube inwards so that the program displays a truncated pyramid.
Draw the cube using triangles instead of quadrangles. The vertices don't change, but the faces do. Instead of having six quads, each a list of 4 indexes, you will need twice as many triangles, each with 3 indexes. Each quad should be divided diagonally.
Starting with the cube vertices and faces, create a model of this ten sided shape:
Uncomment drawMesh in the main section. Study how the the polyhedron is constructed.
Remove the middle quadrangle from the mesh by commenting out one line. (Check that the grid becomes visible through it.)