Vectors in Space

Oregon Curriculum Network
Discovering Math with Python


A point vector is simply an object that points, from the origin to a specific location. We usually represent such an object with an arrow, with its tail at (0,0) or whatever, and its head at (x,y).

Rather that pursue Flatland geometry as an end in itself, we will start right away in spatial geometry, showing two classes of vector, one typical, the other somewhat exotic.

In [1]:
class Vector:
    "A point in space"

We're going to want to see our vectors rendered in some way. Visual Python, or VPython, provides an excellent solution. However, we're going to stay with still ray tracings in this Chapter and work with POV-Ray.

Our goal is to build up a data structure for representing a full-fledge polyhedron, a network of edges, connecting around in faces, floating about the origin. We'll use point vectors for the vertexes, pairs of vectors for the edges, and sets of three or more vectors for the faces. Indeed, given faces as clockwise or counterclockwise listings, we can "distill" the edges by going around each face and getting the vertex vector pairs.

In [4]:
class Edge:
    "A pair of vectors"

class Face:
    "A set of vectors in clockwise or counter-clockwise order"

class Polyhedron:
    "A set of faces"

In this Chapter, we focus on developing a Vector class.

Back to Chapter 5: Public Key Cryptography
Continue to Chapter 7: Polyhedrons
Introduction / Table of Contents