+## Backface culling routine
+#
+
+def isFaceVisible(face, obj, cameraObj):
+ """
+ Determine if the face is visible from the current camera.
+ """
+ numvert = len(face)
+ # backface culling
+ a = []
+ a.append(face[0][0])
+ a.append(face[0][1])
+ a.append(face[0][2])
+ a = RotatePoint(a[0], a[1], a[2], obj.RotX, obj.RotY, obj.RotZ)
+ a[0] += obj.LocX - cameraObj.LocX
+ a[1] += obj.LocY - cameraObj.LocY
+ a[2] += obj.LocZ - cameraObj.LocZ
+ b = []
+ b.append(face[1][0])
+ b.append(face[1][1])
+ b.append(face[1][2])
+ b = RotatePoint(b[0], b[1], b[2], obj.RotX, obj.RotY, obj.RotZ)
+ b[0] += obj.LocX - cameraObj.LocX
+ b[1] += obj.LocY - cameraObj.LocY
+ b[2] += obj.LocZ - cameraObj.LocZ
+ c = []
+ c.append(face[numvert-1][0])
+ c.append(face[numvert-1][1])
+ c.append(face[numvert-1][2])
+ c = RotatePoint(c[0], c[1], c[2], obj.RotX, obj.RotY, obj.RotZ)
+ c[0] += obj.LocX - cameraObj.LocX
+ c[1] += obj.LocY - cameraObj.LocY
+ c[2] += obj.LocZ - cameraObj.LocZ
+
+ norm = [0,0,0]
+ norm[0] = (b[1] - a[1])*(c[2] - a[2]) - (c[1] - a[1])*(b[2] - a[2])
+ norm[1] = -((b[0] - a[0])*(c[2] - a[2]) - (c[0] - a[0])*(b[2] - a[2]))
+ norm[2] = (b[0] - a[0])*(c[1] - a[1]) - (c[0] - a[0])*(b[1] - a[1])
+
+ d = norm[0]*a[0] + norm[1]*a[1] + norm[2]*a[2]
+ return (d<0)
+
+
+# ---------------------------------------------------------------------
+#
+## Mesh representation class
+#
+# ---------------------------------------------------------------------
+
+# TODO: a class to represent the needed properties of a 2D vector image
+
+
+# ---------------------------------------------------------------------
+#
+## Vector Drawing Classes
+#
+# ---------------------------------------------------------------------
+
+## A generic Writer
+
+class VectorWriter:
+ """
+ A class for printing output in a vectorial format.
+
+ Given a 2D representation of the 3D scene the class is responsible to
+ write it is a vector format.
+
+ Every subclasses of VectorWriter must have at last the following public
+ methods:
+ - printCanvas(mesh) --- where mesh is as specified before.
+ """
+
+ def __init__(self, fileName, canvasSize):
+ """Open the file named #fileName# and set the canvas size."""
+
+ self.file = open(fileName, "w")
+ print "Outputting to: ", fileName