Skip to content

Commit b2611b7

Browse files
committed
extract Scale vars in Pol::transform
1 parent c86d9ae commit b2611b7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/PDL/Graphics/TriD/Graph.pm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,15 @@ sub transform {
419419
my $i = 0;
420420
barf "Wrong number of arguments to transform $this\n" if @$inds != 3;
421421
$data = $data->dice_axis(0, $inds);
422+
my ($longrange, $latrange) = map $this->{Scale}[$_][1] - $this->{Scale}[$_][0], 0,1;
423+
my $pressure_max = $this->{Scale}[2][1];
422424
$point->slice("(0)") +=
423425
0.5+($data->slice("(0)")-$this->{Center}[0]) /
424-
($this->{Scale}[0][1] - $this->{Scale}[0][0])
426+
$longrange
425427
*cos($data->slice("(1)")*DEG2RAD);
426428
$point->slice("(1)") +=
427429
0.5+($data->slice("(1)")-$this->{Center}[1]) /
428-
($this->{Scale}[1][1] - $this->{Scale}[1][0])
430+
$latrange
429431
*cos($data->slice("(1)")*DEG2RAD);
430432
# Longitude transformation
431433
# $point->slice("(0)") =
@@ -436,7 +438,7 @@ sub transform {
436438
# Vertical transformation
437439
# -7.2*log($data->slice("(2)")/1012.5
438440
$point->slice("(2)") .=
439-
log($data->slice("(2)")/1012.5)/log($this->{Scale}[2][1]/1012.5);
441+
log($data->slice("(2)")/1012.5)/log($pressure_max/1012.5);
440442
$point;
441443
}
442444

0 commit comments

Comments
 (0)