Skip to content

Commit 5eb3e69

Browse files
committed
use PDL 2.103 linvals with spec args
1 parent add6cc1 commit 5eb3e69

7 files changed

Lines changed: 21 additions & 25 deletions

File tree

Makefile.PL

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ WriteMakefile (
2020
VERSION_FROM => 'lib/PDL/Graphics/TriD.pm',
2121
CONFIGURE_REQUIRES => {
2222
'ExtUtils::MakeMaker' => '7.72',
23-
'PDL' => '2.096',
23+
'PDL' => '2.103',
2424
'OpenGL::Modern' => '0.0403',
2525
},
2626
PREREQ_PM => {
27-
'PDL' => '2.096',
27+
'PDL' => '2.103', # allaxislinvals, fixed *linvals
2828
'OpenGL::Modern' => '0.0403',
2929
'OpenGL::GLFW' => '0.0402',
3030
},

lib/PDL/Demos/TriD1.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ eval { # this is in case no NetPBM, i.e. can't load Earth images
237237
($rgb, $rad) = map $rgbrad2->slice($_), '0:2', '3';
238238
($w, $h) = map $rgbrad2->dim($_), 1, 2;
239239
$lonlat = cat(meshgrid(
240-
zeroes($w)->xlinvals(-PI,PI), zeroes($h)->xlinvals(-PI/2,PI/2)
240+
xlinvals(-PI,PI,$w), xlinvals(-PI/2,PI/2,$h)
241241
))->mv(-1,0);
242242
$lonlatrad = $lonlat->append($rad);
243243
$sph = t_spherical()->inverse()->apply($lonlatrad);
@@ -267,8 +267,8 @@ $latinds = indx(($lats + 0.5) * $rgbrad->dim(2));
267267
$loninds = indx((($lons + 1) / 2) * $rgbrad->dim(1));
268268
$rgbrad3 = $rgbrad->slice(':', map [$_->list], $loninds, $latinds)->sever; # zoom
269269
$lonlat3 = cat(meshgrid(
270-
zeroes($rgbrad3->dim(1))->xlinvals($lons->list),
271-
zeroes($rgbrad3->dim(2))->xlinvals($lats->list),
270+
xlinvals($lons->list,$rgbrad3->dim(1)),
271+
xlinvals($lats->list,$rgbrad3->dim(2)),
272272
))->mv(-1,0);
273273
($rgb3, $rad3) = map $rgbrad3->slice($_), '0:2', '3';
274274
$lonlatrad3 = $lonlat3->append($rad3);

lib/PDL/Demos/TriDGallery.pm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ $|.__PACKAGE__.q|::we_opened = !defined $PDL::Graphics::TriD::current_window;
4646
# B/W Mandelbrot... [Tjl]
4747
4848
use PDL; use PDL::Graphics::TriD; # NOTE all demos need this, only showing once
49-
$s=150;$x=zeroes $s,$s;$r=$x->xlinvals(-1.5,0.5);$i=$x->ylinvals(-1,1);
49+
$s=150;$r=xlinvals(-1.5,0.5,$s,$s);$i=ylinvals(-1,1,$s,$s);
5050
$t=$r;$u=$i;
5151
for(0..12){$q=$r**2-$i**2+$t;$h=2*$r*$i+$u;($r,$i)=map{$_->clip(-5,5)}($q,$h);}
5252
imagrgb[($r**2+$i**2)>2.0];
@@ -104,24 +104,24 @@ twiddle3d();
104104

105105
[actnw => q|
106106
# Torus... (barrel) [Tjl]
107-
$s=40;$x=zeroes $s,$s;$t=$x->xlinvals(0,6.284);
108-
$u=$x->ylinvals(0,6.284);$o=5;$i=1;$v=$o+$i*sin$u;
107+
$s=40;$t=xlinvals(0,6.284,$s,$s);
108+
$u=ylinvals(0,6.284,$s,$s);$o=5;$i=1;$v=$o+$i*sin$u;
109109
imag3d([$v*sin$t,$v*cos$t,$i*cos$u]);
110110
# [press 'q' in the graphics window when done]
111111
|],
112112

113113
[actnw => q|
114114
# Ripply torus [Tjl]
115-
$s=40; $x=zeroes 2*$s,$s/2; $t=$x->xlinvals(0,6.284);
116-
$u=$x->ylinvals(0,6.284); $o=5; $i=1; $v=$o+$i*sin $u;
115+
$s=40; $t=xlinvals(0,6.284,2*$s,$s/2);
116+
$u=ylinvals(0,6.284,2*$s,$s/2); $o=5; $i=1; $v=$o+$i*sin $u;
117117
imag3d([$v*sin$t,$v*cos$t,$i*cos($u)+$o*sin(3*$t)]);
118118
# [press 'q' in the graphics window when done]
119119
|],
120120

121121
[actnw => q|
122122
# Ripply torus distorted [Tjl]
123-
$s=40;$x=zeroes 2*$s,$s/2;$t=$x->xlinvals(0,6.284);$u=$x->ylinvals(0,
124-
6.284); $o=5;$i=1;$v=$o-$o/2*sin(3*$t)+$i*sin$u;
123+
$s=40;$t=xlinvals(0,6.284,2*$s,$s/2);$u=ylinvals(0, 6.284,2*$s,$s/2);
124+
$o=5;$i=1;$v=$o-$o/2*sin(3*$t)+$i*sin$u;
125125
imag3d([$v*sin$t,$v*cos$t,$i*cos($u)+$o*sin(3*$t)]);
126126
# [press 'q' in the graphics window when done]
127127
|],

lib/PDL/Graphics/TriD/Contours.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ sub new {
111111
print "ContourInt = ",$options->{ContourInt},"\n"
112112
if $PDL::Graphics::TriD::verbose;
113113
}
114-
$cvals=zeroes(float(), int(($options->{ContourMax}-$options->{ContourMin})/$options->{ContourInt}+1));
115-
$cvals = $cvals->xlinvals(@$options{qw(ContourMin ContourMax)});
114+
$cvals = xlinvals(float(), @$options{qw(ContourMin ContourMax)}, int(($options->{ContourMax}-$options->{ContourMin})/$options->{ContourInt}+1));
116115
} else {
117116
$cvals = $options->{ContourVals};
118117
@$options{qw(ContourMin ContourMax)} = $cvals->minmax;

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,9 @@ sub togl_setup {
127127
$total_chars++;
128128
}
129129
}
130-
$this->{Impl}{idx} = PDL::cat(@i)->clump(1,2);
131-
$this->load_buffer(vert_buf => my $v = PDL::cat(@v)->clump(1,2));
132-
$this->load_buffer(texc_buf => my $tc = PDL::cat(@tc)->clump(1,2));
133-
$this->load_idx_buffer(indx_buf => $this->{Impl}{idx});
130+
$this->load_buffer(vert_buf => PDL::cat(@v)->clump(1,2));
131+
$this->load_buffer(texc_buf => PDL::cat(@tc)->clump(1,2));
132+
$this->load_idx_buffer(indx_buf => $this->{Impl}{idx} = PDL::cat(@i)->clump(1,2));
134133
$this->togl_unbind;
135134
}
136135
sub gdraw {

lib/PDL/Graphics/TriD/Graph.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ sub new {
144144
$options = $this->{Options};
145145
my $ndiv = $options->{NDiv};
146146
my $points = zeroes(PDL::float(),3,3)->append(my $id3 = identity(3));
147-
my $starts = zeroes(PDL::float(),1,$ndiv+1)->ylinvals(0,1)->append(zeroes(PDL::float(),2,$ndiv+1));
147+
my $starts = ylinvals(PDL::float(),0,1,1,$ndiv+1)->append(zeroes(PDL::float(),2));
148148
my $ends = $starts + append(0, ones 2) * -0.1;
149149
my $dupseq = yvals($ndiv+1,3)->flat;
150150
$_ = $_->dup(1,3)->rotate($dupseq) for $starts, $ends;
@@ -180,7 +180,7 @@ sub finish_scale {
180180
my ($min_big, $max_big, $shift) = map $_->dice_axis(0, $got_bigdiff), $min, $max, $diff;
181181
$shift = $shift * 0.05; # don't mutate
182182
$min_big -= $shift, $max_big += $shift;
183-
my $axisvals = zeroes(PDL::float(),3,$this->{NDiv}+1)->ylinvals($this->{Scale}->dog)->t->flat->t;
183+
my $axisvals = ylinvals(PDL::float(),$this->{Scale}->dog,3,$this->{NDiv}+1)->t->flat->t;
184184
$this->{AxisLabelsObj}->set_labels([map sprintf("%.3f", $_), @{ $axisvals->flat->unpdl }]);
185185
}
186186

@@ -293,8 +293,8 @@ sub finish_scale {
293293
# can be changed to topo heights?
294294
my $verts = PDL->zeroes(PDL::float(),3,$ns[0],$ns[1]);
295295
$verts->slice("2") .= 1012.5;
296-
$verts->slice("0") .= $verts->slice("0")->ylinvals($nc[0],$nc[0]+$nadd[0]*($ns[0]-1));
297-
$verts->slice("1") .= $verts->slice("0")->zlinvals($nc[1],$nc[1]+$nadd[1]*($ns[1]-1));
296+
$verts->slice("0")->inplace->ylinvals($nc[0],$nc[0]+$nadd[0]*($ns[0]-1));
297+
$verts->slice("1")->inplace->zlinvals($nc[1],$nc[1]+$nadd[1]*($ns[1]-1));
298298
my $tverts = PDL->zeroes(PDL::float(),3,$ns[0],$ns[1]);
299299
$tverts = $this->transform($tverts,$verts,[0,1,2]);
300300
$this->add_object(PDL::Graphics::TriD::Lattice->new($tverts, {Shading=>0}));

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ sub new {
270270
my @colordims = $colors->dims;
271271
PDL::barf "Lattice: colours must be 3,x,y: got (@colordims)" if @colordims != 3 or $colordims[0] != 3;
272272
PDL::barf "Lattice: colours' x,y must equal points: got colour=(@colordims) points=($x,$y)" if $colordims[1] != $x or $colordims[2] != $y;
273-
my $tc = PDL->zeroes(PDL::float, 2, @colordims[1,2]);
274-
$tc->slice('(0)') .= $tc->slice('(0)')->xlinvals(0,1); # should be inplace but PDL bugfix not yet released XXX
275-
$tc->slice('(1)') .= $tc->slice('(1)')->ylinvals(0,1);
273+
my $tc = PDL::allaxislinvals(PDL::float, 0,1, @colordims[1,2]);
276274
$this->add_object(PDL::Graphics::TriD::Triangles->new($points->clump(1..2), $faceidx, \[$colors, $tc->clump(1..2)], \%less));
277275
}
278276
if ($shading == 0 or $options->{Lines}) {

0 commit comments

Comments
 (0)