Session 7: Distance Meas. - Module A: 3D Distances & Datasets

1. Overview

What's the difference between 2D and 3D?
Plot some 3D data points.
Compute the distance between points.

2. 2D and 3D: What is the Difference?

Think about how we plotted points in 2D. We had two numbers, a coordinate on the x axis, and a coordinate on the y axis. Each of those numbers corresponds to one of two dimensions in 2D. Now, if a dimension is a direction we can travel in and measure, what happens if we want to add a new a completely new direction?

We will call this new direction the third dimension. Now we are working in 3D! Like the previous two dimensions, the third dimension also has a coordinate, let's call it z.

3. Plotting Points in a 3D Space

Start by downloading the program 3Ddistance.py to your programs directory.

We need to define two points. The coordinates for the first point (x1, y1, z1) have been given to you. You get to choose the coordinates for the second point (x2, y2, z2).

Next, update the distance equation so that it computes distances in three dimensions! If you get stuck, think about the difference between the 1D and 2D distance equations.

Before you run the program, see if you can calculate the distance between the points by hand. When you think you have the answer, check it by running 3Ddistance.py. Try it with different points!

Don't forget to save the figure for your web page! Drag the figure to look at the points from a different angle. Also, answer these questions on your webpage!

4. BONUS: Distance Between Points in a 4D Space

Looking for a challenge? Try computing distances in a 4D space.
Use what you've learned from working in 2D and 3D to update your distance formula.
Can you think of an example when working with more than 3 dimensions might be useful?