39 wxPoint
ToScreen(
double aRe,
double aIm )
const
42 constexpr double LIMIT = 1e7;
47 x = std::isfinite( x ) ? std::clamp( x, -LIMIT, LIMIT ) : 0.0;
48 y = std::isfinite( y ) ? std::clamp( y, -LIMIT, LIMIT ) : 0.0;
53 wxRealPoint
ToGamma(
const wxPoint& aPt )
const
65inline bool GammaToImpedance(
double aRe,
double aIm,
double aZ0,
double& aResistance,
double& aReactance )
67 double denom = ( 1.0 - aRe ) * ( 1.0 - aRe ) + aIm * aIm;
69 if( !std::isfinite( denom ) || denom < 1e-12 )
72 aResistance = ( 1.0 - aRe * aRe - aIm * aIm ) / denom * aZ0;
73 aReactance = 2.0 * aIm / denom * aZ0;
78inline double VSWR(
double aGammaMag )
80 if( aGammaMag >= 1.0 )
81 return std::numeric_limits<double>::infinity();
83 return ( 1.0 + aGammaMag ) / ( 1.0 - aGammaMag );
88 if( aGammaMag <= 0.0 )
89 return std::numeric_limits<double>::infinity();
91 return -20.0 * std::log10( aGammaMag );
98 return aReactance / ( 2.0 *
M_PI * aFreq );
103 return 1.0 / ( 2.0 *
M_PI * aFreq * -aReactance );
109 wxRealPoint gamma = aView.
ToGamma( aPos );
110 double newRadius = aView.
radius / aView.
zoom * aNewZoom;
112 return wxRealPoint( gamma.x - ( aPos.x - aView.
center.x ) / newRadius,
113 gamma.y + ( aPos.y - aView.
center.y ) / newRadius );
117inline bool ParseSParamPorts(
const wxString& aVectorName,
long* aResponsePort,
long* aDrivePort )
119 if( !aVectorName.StartsWith( wxS(
"S_" ) ) )
122 wxString rest = aVectorName.Mid( 2 );
124 return rest.BeforeFirst(
'_' ).ToLong( aResponsePort ) && rest.AfterFirst(
'_' ).ToLong( aDrivePort );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
double SeriesCapacitance(double aReactance, double aFreq)
Pan that keeps the gamma point under aPos fixed when the view zooms to aNewZoom.
double SeriesInductance(double aReactance, double aFreq)
double VSWR(double aGammaMag)
wxRealPoint ZoomAboutPoint(const SMITH_VIEW &aView, const wxPoint &aPos, double aNewZoom)
S-parameter vectors are named S_<responsePort>_<drivePort>.
bool ParseSParamPorts(const wxString &aVectorName, long *aResponsePort, long *aDrivePort)
bool GammaToImpedance(double aRe, double aIm, double aZ0, double &aResistance, double &aReactance)
< Impedance of a reflection coefficient, z = z0 ( 1 + gamma ) / ( 1 - gamma ), false at the gamma = 1...
double ReturnLoss(double aGammaMag)
Series equivalent element of a reactance at one frequency, henries for aReactance > 0,...
< Smith chart placement plus pan/zoom, maps a gamma point to a screen pixel and back.
wxRealPoint ToGamma(const wxPoint &aPt) const
wxPoint ToScreen(double aRe, double aIm) const