param(
    [Parameter(Mandatory = $true)][string]$Frames,
    [Parameter(Mandatory = $true)][string]$Pairs,
    [Parameter(Mandatory = $true)][string]$Extrinsic,
    [int]$PairIndex = 0,
    [double]$LeftRollDeg = 0.0,
    [double]$LeftPitchDeg = 0.0,
    [double]$LeftYawDeg = 0.0
)

$ErrorActionPreference = "Stop"
$Repo = Split-Path -Parent $PSScriptRoot
foreach ($Path in @($Frames, $Pairs, $Extrinsic)) {
    if (-not (Test-Path -LiteralPath $Path)) { throw "Input does not exist: $Path" }
}
& python (Join-Path $Repo "code\visualize_pair_3d.py") `
    --frames $Frames --pairs $Pairs --extrinsic $Extrinsic --pair-index $PairIndex `
    --left-rpy-deg $LeftRollDeg $LeftPitchDeg $LeftYawDeg
if ($LASTEXITCODE -ne 0) { throw "Visualization failed with Python exit code $LASTEXITCODE" }
