chapter three

3 Ascending to the 3D World

 

This chapter covers

  • Building a mental model for 3D vectors
  • Doing 3D vector arithmetic
  • Using the dot product and cross product to measure lengths and directions
  • Rendering a 3D object in 2D

The 2D world is easy to visualize, but the real world has three dimensions.  Whether we are using software to design a building, animate a movie, or run an action game, it needs to be aware of the three spatial dimensions in which we live.

In a two-dimensional space like a page of this book, we have a vertical and a horizontal direction.  Adding a third dimension, we could also talk about points or arrows that lie outside of the page, either toward us or away from us.  But, even when they simulate three dimensions, most computer displays are two-dimensional.  Our mission in this chapter will be to build the tools we need to take 3D objects measured by 3D vectors and convert them to 2D so they can show up on the screen.

A sphere is one example of a 3D shape.  A successfully drawn 3D sphere could look like this:

Figure 3.1  : Shading on a 2D circle makes it look like a 3D sphere.

3.1   Picturing vectors in three-dimensional space

3.1.1   Representing 3D vectors with coordinates

3.1.2   3D Drawing in Python

3.1.3   Exercises

3.2   Vector arithmetic in 3D

3.2.1   Adding 3D vectors

3.2.2   Scalar Multiplication in 3D

3.2.3   Subtracting 3D vectors

3.2.4   Computing lengths and distances

3.2.5   Computing angles and directions

3.2.6   Exercises

3.3   The dot product: measuring alignment of vectors

3.3.1   Picturing the dot product

3.3.2   Computing the dot product

3.3.3   Dot products by example

3.3.4   Measuring angles with the dot product

3.3.5   Exercises

3.4   The cross product: measuring oriented area