PDA

View Full Version : get 3D coord from mouse coord?


peptobismol
06-04-2007, 05:07 PM
Math question...


function mapToScreen (xpp:Number, ypp:Number, zpp:Number) : Object {
var pers = d/(d + zpp);
return {x: xpp * pers, y: ypp * pers};
}

function mapTo3D(inx, iny) {
var pers = (d + iny)/d;
var sx = inx * pers;
var sz = iny * pers;
return {x: sx, y: 0, z: sz};
}


I have these 2 functions... mapToScreen() spits back x,y coord projection when you give it x,y,z coord.. That works fine.

Now I want to do the opposite/inverse with mapTo3D where the mouse pointer coord should spit you back x,y,z coord.. (y is always 0).

I'm getting something close but not quite.
thanks for any input.