     // Uncomment these two lines for orthographic projection
     //cam.projMode = PROJ_ORTHO;
     //cam.orthoViewWidth = 3.0;
+    
+    // Compute the points in the Gaussian plot
+    computePoints();
 }
 
 void loop()
 {
     uView.clear(PAGE);
     
-    // Draw Gaussian plot
-    drawGaussPlot();
+    // Update plot transform and draw points
+    plotTrans = Transform(0, 0, angle += 2, 1, 1, 3, 0, 0, 0);
+    drawPoints();
     
     uView.display();
     delay(UPDATE_DELAY);
 }
 
-void drawGaussPlot()
+void computePoints()
 {
     float ux = 0, uy = 0;      // Means
-    float sx = 0.5, sy = 0.5;  // Standard deviations
+    float sx = 0.5, sy = 0.7;  // Standard deviations
     
     // Plotting options
     float minX = -3, maxX = 3;
     float minY = -3, maxY = 3;
-    float xStep = 0.25, yStep = 0.25;
+    float xStep = 0.75, yStep = 0.75;
     
-    byte numPtsX = (maxX - minX) / xStep;
-    byte numPtsY = (maxY - minY) / yStep;
+    numPtsX = (maxX - minX) / xStep;
+    numPtsY = (maxY - minY) / yStep;
     
-    for (byte n = 0; n < numPtsX; n++)
+    points = new point3*[numPtsX];
+    
+    if (points != NULL)
     {
-        for (byte m = 0; m < numPtsY; m++)
+        for (unsigned int n = 0; n < numPtsX; n++)
         {
-            // Compute Gaussian point
-            float x = (n * xStep) + minX;
-            float y = (m * yStep) + minY;
-            float z = gauss(x, y, ux, uy, sx, sy);
-            point3 pt3 = { x, y, z };
+            // Try to allocate next row of points
+            points[n] = new point3[numPtsY];
             
-            // Transform and project 3D point
-            point2 pt2 = cam.project(plotTrans * pt3);
-            
-            // Draw point if not clipped
-            if (!isnan(pt2.x))
+            if (points[n] != NULL)
             {
-                uView.pixel(pt2.x, pt2.y);
+                for (unsigned int m = 0; m < numPtsY; m++)
+                {
+                    // Compute Gaussian point
+                    float x = (n * xStep) + minX;
+                    float y = (m * yStep) + minY;
+                    float z = gauss(x, y, ux, uy, sx, sy);
+                    
+                    points[n][m] = { x, y, z };
+                }
             }
         }
     }

        ((y - uy) * (y - uy) / (2 * sy * sy))))
        / (2 * PI * sx * sy);
}


#define UPDATE_DELAY  0

// Transform for plot
Transform plotTrans;
float angle = 0;

// Array of plot points
point3 **points;
unsigned int numPtsX, numPtsY;

// Create a camera
Camera cam(LCDWIDTH, LCDHEIGHT);
