Unified · Split
| @@ -1696,11 +1696,13 @@ static int stereographic_to_xyz(const V360Context *s, · 1695 unmodified lines | ||
| 1696 | 1696 | { |
| 1697 | 1697 | const float x = ((2.f * i + 1.f) / width - 1.f) * s->flat_range[0]; |
| 1698 | 1698 | const float y = ((2.f * j + 1.f) / height - 1.f) * s->flat_range[1]; |
| 1699 | − const float xy = x * x + y * y; | |
| 1699 | + const float r = hypotf(x, y); | |
| 1700 | + const float theta = atanf(r) * 2.f; | |
| 1701 | + const float sin_theta = sinf(theta); | |
| 1700 | 1702 | |
| 1701 | − vec[0] = 2.f * x / (1.f + xy); | |
| 1702 | − vec[1] = (-1.f + xy) / (1.f + xy); | |
| 1703 | − vec[2] = 2.f * y / (1.f + xy); | |
| 1703 | + vec[0] = x / r * sin_theta; | |
| 1704 | + vec[1] = -y / r * sin_theta; | |
| 1705 | + vec[2] = -cosf(theta); | |
| 1704 | 1706 | |
| 1705 | 1707 | normalize_vector(vec); |
| 1706 | 1708 | |