Monado OpenXR Runtime
hg_stereographic_unprojection.hpp
Go to the documentation of this file.
1// Copyright 2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Stereographic unprojection
6 * @author Moshi Turner <moses@collabora.com>
7 * @ingroup tracking
8 */
9
10#pragma once
12
13static inline Eigen::Vector3f
14stereographic_unprojection(float sg_x, float sg_y)
15{
16 float X = sg_x;
17 float Y = sg_y;
18
19 float denom = (1 + X * X + Y * Y);
20
21 float x = (2 * X) / denom;
22 float y = (2 * Y) / denom;
23 float z = (-1 + X * X + Y * Y) / denom;
24
25 // forward is -z
26 return {x, y, z};
27 // return {x / -z, y / -z};
28}
Interoperability helpers connecting internal math types and Eigen.