plot(s)


   //Plots a DIV at the correct position and resizes it
   //===================================================================
   function plotPoint(name, pos,age) {
    //Create objects for DIV
    obj = document.getElementById(name);
    css = document.getElementById(name).style;
    
    f = viewport.a.z - camera.z;  //Focal length
  
    //From ratios of a triangle get position of point relative to camera
    cy = (pos.y-camera.y) * f / (pos.z-viewport.a.z);  
    cx = (pos.x-camera.x) * f / (pos.z-viewport.a.z);
  
    //Position of point relative to viewport
    py = parseInt(camera.y + cy - viewport.a.y); 
    px = parseInt(camera.x + cx - viewport.a.x);
  
    if(pos.z > viewport.a.z && px > 0 && py > 0 && py < viewport.b.y - viewport.a.y && px < viewport.b.x - viewport.a.x) { 
     //Move object to correct position
     //alert("Moving " + name + " to (" + px + "," + py + ")");
     css.visibility = "";
     d = (150 - pos.z);
     css.backgroundColor = "rgb(" + (250-age) + "," + (200-age*2) + "," + (100-age) + ")";
     d /= 10000 / (viewport.b.x - viewport.a.x); //scale pixel to \%age of viepwort
     if(d<1) d=1;
     css.width = 3*d;
     css.height = 4*d;
     css.left = 200 + 2 * ( px - d/2 + viewport.c.x);
     css.top = -100 + 2 * ( 2 * py - d/2 + viewport.c.y);
     css.zIndex = (100 - pos.z) + 1000;
    } else {
     css.visibility = "hidden";  //on this side of the viewport so hide it
    }
   }