(reconstruction: Reconstruction)
| 17 | * Uses median of camera positions for robustness to outliers. |
| 18 | */ |
| 19 | export function computeCenterAtOrigin(reconstruction: Reconstruction): Sim3d { |
| 20 | const positions: THREE.Vector3[] = []; |
| 21 | |
| 22 | for (const image of reconstruction.images.values()) { |
| 23 | positions.push(getImageWorldPosition(image)); |
| 24 | } |
| 25 | |
| 26 | if (positions.length === 0) { |
| 27 | return identitySim3d(); |
| 28 | } |
| 29 | |
| 30 | const centerX = median(positions.map((p) => p.x)); |
| 31 | const centerY = median(positions.map((p) => p.y)); |
| 32 | const centerZ = median(positions.map((p) => p.z)); |
| 33 | |
| 34 | return { |
| 35 | scale: 1, |
| 36 | rotation: new THREE.Quaternion(), |
| 37 | translation: new THREE.Vector3(-centerX, -centerY, -centerZ), |
| 38 | }; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Compute transform to normalize scale (fit scene to specified extent). |
no test coverage detected