Skip to content

Commit 6e9e4df

Browse files
committed
make FaceAxes::normalise_scale work on mins,maxes
1 parent 408ab58 commit 6e9e4df

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

lib/PDL/Graphics/TriD/Graph.pm

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,25 +211,25 @@ use fields qw(LatticeObj Names Center);
211211
sub normalise_scale { # Normalize the smallest differences away.
212212
my ($this) = @_;
213213
my @dist;
214-
my $bounds = $this->{Bounds}->t->unpdl;
215-
for (@$bounds) {
216-
if (abs($_->[0] - $_->[1]) < 0.000001) {
217-
$_->[1] = $_->[0] + 1;
214+
my ($mins, $maxes) = @{ $this->{Bounds}->unpdl };
215+
for (0..$#$mins) {
216+
if (abs($mins->[$_] - $maxes->[$_]) < 0.000001) {
217+
$maxes->[$_] = $mins->[$_] + 1;
218218
}
219-
push(@dist,$_->[1]-$_->[0]);
219+
push(@dist,$maxes->[$_]-$mins->[$_]);
220220
}
221221
# Normalize longitude and latitude bounds
222222
if ($dist[1] > $dist[0]) {
223-
$bounds->[0][0] -= ($dist[1]-$dist[0])/2;
224-
$bounds->[0][1] += ($dist[1]-$dist[0])/2;
223+
$mins->[0] -= ($dist[1]-$dist[0])/2;
224+
$maxes->[0] += ($dist[1]-$dist[0])/2;
225225
} elsif ($dist[0] > $dist[1] && $dist[0]<90) {
226-
$bounds->[1][0] -= ($dist[0]-$dist[1])/2;
227-
$bounds->[1][1] += ($dist[0]-$dist[1])/2;
226+
$mins->[1] -= ($dist[0]-$dist[1])/2;
227+
$maxes->[1] += ($dist[0]-$dist[1])/2;
228228
} elsif ($dist[0] > $dist[1]) {
229-
$bounds->[1][0] -= (90-$dist[1])/2;
230-
$bounds->[1][1] += (90-$dist[1])/2;
229+
$mins->[1] -= (90-$dist[1])/2;
230+
$maxes->[1] += (90-$dist[1])/2;
231231
}
232-
$bounds;
232+
($mins, $maxes);
233233
}
234234
sub add_lattice_axis {
235235
my ($this) = @_;
@@ -284,7 +284,7 @@ sub add_scale {
284284

285285
sub finish_scale {
286286
my ($this) = @_;
287-
$this->{Bounds} = PDL->pdl(PDL::float(), $this->normalise_scale)->t;
287+
$this->{Bounds} = PDL->pdl(PDL::float(), $this->normalise_scale);
288288
$this->add_lattice_axis;
289289
}
290290

@@ -341,7 +341,7 @@ sub add_scale {
341341

342342
sub finish_scale {
343343
my ($this) = @_;
344-
$this->{Bounds} = PDL->pdl(PDL::float(), $this->normalise_scale)->t;
344+
$this->{Bounds} = PDL->pdl(PDL::float(), $this->normalise_scale);
345345
$this->add_lattice_axis;
346346
}
347347

0 commit comments

Comments
 (0)