Unified · Split
| @@ -2048,16 +2048,15 @@ static void dfisheye_to_xyz(const V360Context *s, · 2047 unmodified lines | ||
| 2048 | 2048 | const float uf = ((2.f * ei) / ew - 1.f) * scale; |
| 2049 | 2049 | const float vf = ((2.f * j) / eh - 1.f) * scale; |
| 2050 | 2050 | |
| 2051 | − const float phi = M_PI + atan2f(vf, uf * m); | |
| 2052 | − const float theta = m * M_PI_2 * (1.f - hypotf(uf, vf)); | |
| 2051 | + const float h = hypotf(uf, vf); | |
| 2052 | + const float lh = h > 0.f ? h : 1.f; | |
| 2053 | + const float theta = m * M_PI_2 * (1.f - h); | |
| 2053 | 2054 | |
| 2054 | − const float sin_phi = sinf(phi); | |
| 2055 | − const float cos_phi = cosf(phi); | |
| 2056 | 2055 | const float sin_theta = sinf(theta); |
| 2057 | 2056 | const float cos_theta = cosf(theta); |
| 2058 | 2057 | |
| 2059 | − vec[0] = cos_theta * cos_phi; | |
| 2060 | − vec[1] = cos_theta * sin_phi; | |
| 2058 | + vec[0] = cos_theta * uf / lh; | |
| 2059 | + vec[1] = cos_theta * -vf / lh; | |
| 2061 | 2060 | vec[2] = sin_theta; |
| 2062 | 2061 | |
| 2063 | 2062 | normalize_vector(vec); |