Screen To WorldXY - Exact under tip of pointer

As the topic says, I’m looking for a direct, well-performing way to get the exact spot on WorldXY plane - going from there to an arbitrary plane should be fairly easy as long as we operate on xforms, though no matter how hard I would try, already mentioned methods in:

I got wrong results that do not match the left-bottom Rhino window indication of XYZ, according to the methods mentioned above, code called in derived MouseCallback OnMouseMove:

var vp = e.View.ActiveViewport;
var screenToWorld = vp.GetTransform(Rhino.DocObjects.CoordinateSystem.Screen, Rhino.DocObjects.CoordinateSystem.World);
var currentWorldPoint = screenToWorld * new Point3d(e.ViewportPoint.X, e.ViewportPoint.Y, 0);

RhinoApp.WriteLine(currentWorldPoint.ToString());

It should be an elegant way to get the spot, instead of that, I get variable Z results, like it would be some kind of intermediate xform to intermediate XYZ space, moving around origin results in:

I also noticed it depends on the zoom level (change of range of values), and it’s worth mentioning that it is related to perspective view, as X and Y in top view seem to be ok, though I get Z around ~10.5046

Additional example where it finds around origin (XY) values (black dot in vieport):


@dale Would you mind kicking in and leaving a hint on this?

Hi @D-W ,
I’d go for Viewport.GetFrustumLine → intersect ray with Plane.WorldXY → point = ray.PointAt(t).
Very easy and straightforward,
Farouk

^ This is what I’ve had with success as well

Hi guys! Thanks for your insight @farouk.serragedine & @michaelvollrath . That’s how I already handle it with perfect results in later delta calculations, though the idea was to use only matrices. Pure xform * xform - at least this should be the most performant way, fastest possible.