.net3dtransformationslimdxplane

Transform point coordinates from 3D space to a generic 2D plane in SlimDX


I need to project a SlimDX.Vector3 (X, Y and Z components) in a generic 2D plane (defined with SlimDX.Plane, with 3 Vector3). Please note that the plane is generic, and it is not the screen plane (otherwise, Vector3.Project could be used). I need to determine the Tranformation Matrix (or the Quaternion) from the 3D space to the 2D plane, but I don't know how. The origin of the plane can be whatever, e.g. the first point used to define the plane.

Anyone can help?


Solution

  • I think what you want is the separation of the point to the plane (along the normal) which is given with

    float h = Plane.DotNormal(plane, point);
    

    Then subtract this amount along the plane normal from the point

    Vector3 proj = point - h*plane.Normal;
    

    The resulting point should lie on the plane.