mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-10 08:53:41 +00:00
Interpolate calibration with magnitude/phase instead of real/imag
This commit is contained in:
parent
9660b4e58b
commit
b6f26eb6dc
3 changed files with 27 additions and 6 deletions
|
|
@ -237,3 +237,21 @@ bool Util::firmwareEqualOrHigher(QString firmware, QString compare)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::complex<double> Util::interpolateMagPhase(const std::complex<double> &from, const std::complex<double> &to, double alpha)
|
||||
{
|
||||
auto magFrom = abs(from);
|
||||
auto magTo = abs(to);
|
||||
auto phaseFrom = arg(from);
|
||||
auto phaseTo = arg(to);
|
||||
// unwrap phase
|
||||
if(phaseTo - phaseFrom > M_PI) {
|
||||
phaseTo -= 2*M_PI;
|
||||
} else if(phaseTo - phaseFrom < -M_PI) {
|
||||
phaseTo += 2*M_PI;
|
||||
}
|
||||
auto magInterp = magFrom * (1.0 - alpha) + magTo * alpha;
|
||||
auto phaseInterp = phaseFrom * (1.0 - alpha) + phaseTo * alpha;
|
||||
|
||||
return std::polar<double>(magInterp, phaseInterp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue