
/*
   The code below shows you how to do the perspective
   projection of a 3D point onto your java applet.

   The numbers below are just examples.  You should use
   the actual width and height of your applet.  Also, you
   can change FL (focal length) to create a different
   look (wide-angle or zoom-lens effects), although
   FL = 10.0 produces pretty good looking results.
*/

   int w = 640; // THE WIDTH OF YOUR APPLET IN PIXELS

   int h = 480; // THE HEIGHT OF YOUR APPLET IN PIXELS

   double FL = 10.0; // "FOCAL LENGTH" OF THE CAMERA

   public void projectPoint(double[] xyz, int[] pxy) {

      // INPUT: YOUR POINT IN 3D

      double x = xyz[0];
      double y = xyz[1];
      double z = xyz[2];

      // OUTPUT: PIXEL COORDINATES TO DISPLAY YOUR POINT

      pxy[0] = w / 2 + (int)(h * x / (FL - z));
      pxy[1] = h / 2 - (int)(h * y / (FL - z));
   }

