/// <summary> /// Unproject a Vector2 on image space in (u, v) coordinate to a Vector3 world space /// </summary> public Vector3 UnprojRaw(Vector2 p, DoUndistort undistort = DoUndistort.NO, bool invertX = false, bool invertY = false) { float x = (p.x - Cx) / Fx; float y = (p.y - Cy) / Fy; x = invertX ? -x : x; y = invertY ? -y : y; Vector2 undis; if (undistort == DoUndistort.YES) { undis = Undistort(x, y); return(new Vector3(undis.x, undis.y, 1.0f).normalized); } else { return(new Vector3(x, y, 1.0f).normalized); } }
/// <summary> /// Unproject a Vector2 on image space in [0, 1] scale to a Vector3 world space /// </summary> public Vector3 Unproj(Vector2 p, DoUndistort undistort = DoUndistort.NO, bool invertX = false, bool invertY = false) { return(UnprojRaw(new Vector2(p.x * Width, p.y * Height), undistort, invertX, invertY)); }