in reply to Re: PDL questions
in thread PDL questions

thank you Rob very much for uploading opengl 0.63 , now the examples run more smoothly, and i get rid of from strange hang out sometimes when running the examples using the beautiful 3D PDL::Graphics::TriD module here is an animated mandelbrot i copied from TriDGallery.PM in "C:\Perl\site\lib\PDL\Demos"
it is displaying an animated color mandel set like this :
http://img580.imageshack.us/img580/1223/mandel.png
indeed i have astonished by the versatile and deep features this PDL module has especially with its 2D and 3D features.
use PDL; use PDL::Graphics::TriD; #Color Mandelbrot animation nokeeptwiddling3d(); $a=zeroes 300,300;$r=$a->xlinvals(-1.5,0.5); $i=$a->ylinvals(-1,1); $t=$r;$u=$i; for(1..30){$q=$r**2-$i**2+$t; $h = 2*$r*$i+$u; $d=$r**2+$i**2; $a=lclip($a,$_*($d>2.0)*($a==0)); ($r,$i) = map{$_->clip(-5,5)}$q,$h; imagrgb[($a==0)*($r/2+0.75),($a==0)*($i+1)/2,$a/30]}; # [press 'q' in the graphics window when done] keeptwiddling3d(); twiddle3d();

regarding the error "Interface HASH(0X25C224) is not known!" i still get it even if i add
use PDL;
use PDL::Graphics2D;
use PDL::Graphics::PGPLOT::Window;
use PDL::Graphics::PGPLOT;
it gives the error at the line

my $w = PDL::Graphics2D->new($winopt);

if i use "PDL::Graphics::PGPLOT::Window" instead as the code below i get an error "Undefined subroutine &main::imag2d called at err.pl line 13"
use PDL; use PDL::Graphics2D; #imports imag2d() and twiddle() use PDL::Graphics::PGPLOT::Window; use PDL::Graphics::PGPLOT; my $winopt = {Device => "/GW", WindowWidth => 7, Aspect => 1}; #my $w = PDL::Graphics2D->new($winopt); my $w = PDL::Graphics::PGPLOT::Window->new($winopt); $a = sequence(64,48,3); # make test RGB image $a = $a->mv(2,0); # color must be dim(0) with size [0..4] $a /= $a->max; # pixel values in [0.0,1.0] $a = sin(10*$a); $w = imag2d($a);


it can be an ms windows specific problem, sure the developer get it working since the example is here :
http://kobesearch.cpan.org/htdocs/PDL/PDL/Graphics2D.html
so i will post to the pdl forum

thank you Rob for all your efforts.

Replies are listed 'Best First'.
Re^3: PDL questions
by Anonymous Monk on Sep 27, 2010 at 13:49 UTC
    i have tried the above error examples on linux mint, just changing the device to /xs instead of /GW:
    my $winopt = {Device => "/xs", WindowWidth => 7, Aspect => 1};

    and i got the same errors, the first one is
    Interface HASH(0X9F05818) is not known!
    regards

      Again, you're passing $winopt as the first parameter. $winopt is a hash reference, but PDL::Graphics2D wants an "Interface" (whatever it means by this) as the first parameter, and it tells you that it is unhappy with a hash reference. See the PDL::Graphics2D documentation.

      $win = PDL::Graphics2D->new(<Interface>, <Options>);

      Looking inside, there is currently only one "interface" defined: 'PGPLOT'. So try passing that as the first argument to new().

      i have found some solution, inspired by many posts especially a message with a title "imag2d.pdl for test" :
      http://mailman.jach.hawaii.edu/pipermail/perldl/2009-December/002665.html and
      http://mailman.jach.hawaii.edu/pipermail/perldl/2010-January/002716.html
      we need a file "imag2d.pdl" not in the pdl package, and to use PDL::AutoLoader, as explained in the above message so putting the file imag2d.pdl in the same folder as the following code can run successfully the code with a red dusk like image. i run the code in windows xp activestate perl 5.10
      use PDL; use PGPLOT; use PDL::Graphics2D; #imports imag2d() and twiddle() use PDL::AutoLoader; our @PDLLIB; push @PDLLIB, '.'; my $winopt = {Device => '/GW', WindowWidth => 7, Aspect => 1}; my $w = PDL::Graphics2D->new('PGPLOT'); $a = sequence(64,48,3); # make test RGB image $a = $a->mv(2,0); # color must be dim(0) with size [0..4] $a /= $a->max; # pixel values in [0.0,1.0] $a = sin(10*$a); imag2d($a);

      there may be more improvements, thanks for all
      thank you BrowserUk, as always you supply a clear specific answer for the non prof users. i have applied your suggestion
      my $w = PDL::Graphics2D->new('PGPLOT');
      and added also use PGPLOT;
      and yes i can run all the code and display a window like this
      http://img409.imageshack.us/img409/1384/erroriu.png
      but with an error at the final line
      "Can't locate object method "imag2d" via package "PDL" at err.pl line 13"
      this is the same using windows xp and linux mint
      i choose linux mint because it is super easy to install modules directly from their site. and indeed it is the first time i am using linux. also i want to thank zentara for the second version of the "PDL 3d image cube" example in www.perlmonks.org/?node_id=591731
      it is working well rotate and zoom in and out with the mouse.
      regards

        If you want help, you will need to show us the actual code you're running. Also, please don't post screenshots where the simple source code and text output of Perl suffices. That makes it much easier for us to reproduce the problem and thus helps us help you better.

        I suspect that, for some unshown reason, you have something like the following in your code at line 13:

        my $p = sequence(64,48,3); # make test RGB image my $win = $p->imag2d();

        The documentation of PDL::Image2D claims that the usage is not as a method but as a separate function:

        use PDL::Graphics2D; my $p = sequence(64,48,3); # make test RGB image my $win = imag2d( $p );