(p: Vec2, i: CameraIntrinsics)
| 855 | |
| 856 | // Mirrors distortRadTanFisheye(). |
| 857 | function _glslRadTanFisheye(p: Vec2, i: CameraIntrinsics): Vec2 { |
| 858 | const r = Math.hypot(p.x, p.y); |
| 859 | if (r < 0.00001) return { x: p.x, y: p.y }; |
| 860 | const theta = Math.atan(r); |
| 861 | const uux = p.x * (theta / r); |
| 862 | const uuy = p.y * (theta / r); |
| 863 | const theta2 = uux * uux + uuy * uuy; // = theta² |
| 864 | const theta4 = theta2 * theta2; |
| 865 | const theta6 = theta4 * theta2; |
| 866 | const theta8 = theta4 * theta4; |
| 867 | const theta10 = theta8 * theta2; |
| 868 | const theta12 = theta10 * theta2; |
| 869 | const thRadial = 1.0 + i.k1 * theta2 + i.k2 * theta4 + i.k3 * theta6 |
| 870 | + i.k4 * theta8 + i.k5 * theta10 + i.k6 * theta12; |
| 871 | const x = thRadial * uux; |
| 872 | const y = thRadial * uuy; |
| 873 | const x2 = x * x, y2 = y * y; |
| 874 | const xy = x * y; |
| 875 | const r2 = x2 + y2; |
| 876 | const r4 = r2 * r2; |
| 877 | // COLMAP convention: i.p1=COLMAP p0, i.p2=COLMAP p1 |
| 878 | const dxTang = i.p1 * (r2 + 2.0 * x2) + 2.0 * i.p2 * xy; |
| 879 | const dyTang = 2.0 * i.p1 * xy + i.p2 * (r2 + 2.0 * y2); |
| 880 | const dxTp = i.sx1 * r2 + i.sy1 * r4; |
| 881 | const dyTp = i.sx2 * r2 + i.sy2 * r4; |
| 882 | // p + delta, where delta = vec2(x + dxTang + dxTp − p.x, y + dyTang + dyTp − p.y) |
| 883 | return { x: x + dxTang + dxTp, y: y + dyTang + dyTp }; |
| 884 | } |
| 885 | |
| 886 | // Mirrors distortDivision(). |
| 887 | function _glslDivision(p: Vec2, i: CameraIntrinsics): Vec2 { |
no outgoing calls
no test coverage detected