#!/usr/bin/perl use warnings; use PDL; use PDL::Graphics::TriD; # POLAR2D A 2-D polar coordinate system. [$piddle] is interpreted as the z coordi # nate over theta and r (theta = the first dimension of the piddle). $size = 25; $x = ( xvals zeroes $size+ 1, $size + 1 );# / $size; print "$x\n"; print join ' ',dims $x; print "\n"; $y = ( yvals zeroes $size+ 1, $size + 1 );# / $size; #$z = 0.5 + 0.5 * ( sin( $x * 6.3 ) * sin( $y * 6.3 ) )**3; # Bumps $z= $x * 10; $r = $x; $g = $y; $b = $z; # The reason for the [] around $x,$y,$z: # 1. You can give all the coordinates and colors in one piddle. $c = ( zeroes 3, $size + 1 ) / $size; $coords = sin( ( 3 + 3 * xvals $c) * yvals $c); $colors = $coords; print "hit q to continue\n"; # 2. You can use defaults inside the brackets: lattice3d [ $z ], [ $r ]; # Note: no $x, $y, and $r is greyscale print "hit q to continue\n"; # 3. You can plot in certain other systems as defaults imag3d_ns [ POLAR2D, $z ], [ $r, $g, $b ]; # Draw the familiar # bumpy surface in polar # coordinates #### #!/usr/bin/perl use warnings; use strict; use PDL; use PDL::Graphics::TriD; keeptwiddling3d(); my $piddle = pdl( [ [1,1,1],[2,2,2],[3,3,3],[4,4,4],[5,5,5],[6,6,6],[7,7,7],[8,8,8], [1,0,1] ] ); spheres3d $piddle ;