This commit is contained in:
DiSlord 2020-06-20 12:31:35 +03:00
commit 76223f5e25
4 changed files with 30 additions and 8 deletions

19
plot.c
View file

@ -491,6 +491,14 @@ reactance(const float *v)
return zi;
}
static float
qualityfactor(const float *v)
{
float i = 2*v[1];
float r = (1+v[0])*(1-v[0]) - v[1]*v[1];
return fabs(i / r);
}
static void
cartesian_scale(float re, float im, int *xp, int *yp, float scale)
{
@ -551,6 +559,9 @@ trace_into_index(int t, int i, float array[POINTS_COUNT][2])
case TRC_X:
v-= reactance(coeff) * scale;
break;
case TRC_Q:
v-= qualityfactor(coeff) * scale;
break;
case TRC_SMITH:
//case TRC_ADMIT:
case TRC_POLAR:
@ -653,6 +664,10 @@ trace_get_value_string(int t, char *buf, int len, float array[POINTS_COUNT][2],
format = "%.2F"S_OHM;
v = reactance(coeff);
break;
case TRC_Q:
format = "%.1f";
v = qualityfactor(coeff);
break;
case TRC_SMITH:
format_smith_value(buf, len, coeff, frequencies[i]);
return;
@ -713,6 +728,10 @@ trace_get_value_string_delta(int t, char *buf, int len, float array[POINTS_COUNT
format = "%.2F"S_OHM;
v = reactance(coeff);
break;
case TRC_Q:
format = "%.1f";
v = qualityfactor(coeff);
break;
//case TRC_ADMIT:
case TRC_POLAR:
plot_printf(buf, len, "%.2f%+.2fj", coeff[0], coeff[1]);