Just as you say. Employing a square function, per your example, seems to work out more like the ones I was thinking about. A distortion from decibels, and also not really undoing logarithmic, as you observed. But perhaps with the advantage of putting the ring for 0 dBi very nearly at the exact center, allowing more space for the primary data-of-interest. In the sample PNG graphic (a screenshot from Nec2Go) it is clear that they've done similar. The values for -20, -30, -40 are scrunched down in the very center. And it is -10 dBi which is at about the middle rung, while +8.9 dBi is the outermost rung (that being max output).
At least my puzzle is solved! It must wait until after work before I can try putting it into an SVG and deciding whether to keep it. Chances are, maybe you've persuaded me in that direction. In which case, I'll leave it as was. Alternately, I might keep both and make the choice selectable. I thank you for your kind assistance.
#!C:\Users\gstarl\Strawberry\perl\bin\perl
# Azimuth_Scaling_Example.pl
my $scale_min = 0; # Center point of radius in pixels.
my $scale_max = 100; # Outer circumference in pixels.
my $scale_span = $scale_max - $scale_min;
# Example fake data
# Also, positions of rings in azimuthal plot.
my @data = (-50, -40, -30, -20, -10, 0, 10, 20);
# Extract limits and span from data array.
sub get_min_max_span {
my @data = @_;
my $min;
my $max;
for my $i (0 .. $#data) {
if ($i == 0) {
$min = $max = $data[0]
} else {
$min = $data[$i] if $min > $data[$i];
$max = $data[$i] if $max < $data[$i];
}
}
return $min, $max, $max-$min;
}
# Collect from data.
my ($data_min, $data_max, $data_span) = get_min_max_span(@data);
# Scale values in dBi for plot as pixels.
# Also to place the dBi rings on plot.
sub scale_value_for_graph {
my ($value, $data_min, $data_max, $data_span, $scale_max) = @_;
return ($value - $data_min)**2 * $scale_max / $data_span**2;
}
# Try it out. Goodie! The zero dBi position is about in the middle.
for (@data) {
print "\n$_ -> " . scale_value_for_graph($_, $data_min, $data_max,
+ $data_span, $scale_max);
}
|