function persp (dp, p) { // compute perspective projection of data point into viewplane // (vp+t(dp-vp),vd)=0 so t=-(vd,vp)/(vd,dp-vp) // doesn't require basis for that plane // so it can be used to set i2 in initialization! var t; dir = new Array(3); centerv = new Array(3); for (i=0; i<3; i++) dir[i] = dp[i]-vp[i]; t = -dot3(vd, vp)/dot3(vd, dir); for (i=0; i<3; i++) p[i] = vp[i]+t*dir[i]; } function cross (v0, v1, v2) { v2[0] = v1[2]*v0[1]-v1[1]*v0[2]; v2[1] = v1[0]*v0[2]-v1[2]*v0[0]; v2[2] = v1[1]*v0[0]-v1[0]*v0[1];} function icoord (ip, i1, i2, ic) { ic[0] = dot3(ip, i1); ic[1] = dot3(ip, i2); } function co2pix(ic, pix){ pix[0]=xcenter+xconv*ic[0]; pix[1]=ycenter-yconv*ic[1]; } function point2pixels(point,pixels){ proj = new Array(3); implco = new Array(2); persp(point,proj); // ip vector of intersection of vp v and image icoord(proj, i1, i2, implco);// ic image coords co2pix(implco,pixels); }