@@ -35,10 +35,50 @@ sub normalise_as {
3535 die " Given 1D ndarray as colour but no points to match" if !defined $points ;
3636 return $this -> cdummies($what -> float,$points );
3737 }
38- return PDL::Graphics::TriD:: realcoords($as , $what ) if !defined $points or defined $what ;
38+ return realcoords($as , $what ) if !defined $points or defined $what ;
3939 $this -> cdummies(PDL-> pdl(PDL::float(),1,1,1),$points );
4040}
4141
42+ # Allowable forms:
43+ # x(3,..) [x(..),y(..),z(..)]
44+ sub realcoords {
45+ my ($type ,$c ) = @_ ;
46+ if (ref $c ne " ARRAY" ) {
47+ my $dim0 = $c -> getdim(0);
48+ confess " If one ndarray given for coordinate, must be (2|3,...) or have default interpretation" if $dim0 != 2 and $dim0 != 3;
49+ return $c -> float;
50+ }
51+ my @c = @$c ;
52+ if (!ref $c [0]) {$type = shift @c }
53+ confess " Must have 1..3 array members for coordinates" if !@c || @c >3;
54+ if (@c == 1 and $type eq " SURF2D" ) {
55+ # surf2d -> this is z axis
56+ @c = ($c [0]-> xvals,$c [0]-> yvals,$c [0]);
57+ } elsif (@c == 1 and $type eq " POLAR2D" ) {
58+ my $t = 6.283 * $c [0]-> xvals / ($c [0]-> getdim(0)-1);
59+ my $r = $c [0]-> yvals / ($c [0]-> getdim(1)-1);
60+ @c = ($r * sin ($t ), $r * cos ($t ), $c [0]);
61+ } elsif (@c == 1 and $type eq " COLOR" ) {
62+ # color -> 1 ndarray = grayscale
63+ @c = @c [0,0,0];
64+ } elsif (@c == 1 and $type eq " LINE" ) {
65+ @c = ($c [0]-> xvals, $c [0], 0);
66+ } elsif (@c == 2 and $type eq " LINE" ) {
67+ @c = (@c [0,1], $c [0]-> xvals);
68+ }
69+ # XXX
70+ confess " Must have 3 coordinates if no interpretation (here '$type ')" if @c != 3;
71+ # allow a constant (either pdl or not) to be introduced in one dimension
72+ foreach (0..2) {
73+ if (ref ($c [$_ ]) ne " PDL" or $c [$_ ]-> nelem==1) {
74+ $c [$_ ] = $c [$_ ]*(PDL-> ones($c [($_ +1)%3 ]-> dims));
75+ }
76+ }
77+ my $g = PDL::ImageND::combcoords(@c );
78+ $g -> dump if $PDL::Graphics::TriD::verbose ;
79+ $g ;
80+ }
81+
4282sub check_options {
4383 my ($this ) = @_ ;
4484 my $opts = $this -> get_valid_options();
0 commit comments