"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Graphics/TriD/TriD/Polygonize.pm" between
PDL-2.076.tar.gz and PDL-2.077.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

Polygonize.pm  (PDL-2.076):Polygonize.pm  (PDL-2.077)
skipping to change at line 76 skipping to change at line 76
[0,-1,0], [0,-1,0],
[0,1,0], [0,1,0],
[-1,0,0], [-1,0,0],
[1,0,0], [1,0,0],
]); ]);
sub contourpolygonize { sub contourpolygonize {
my($in,$oscale,$scale,$func) = @_; my($in,$oscale,$scale,$func) = @_;
my $ccube = $cube * $oscale; my $ccube = $cube * $oscale;
my $maxstep=0; my $maxstep=0;
while(($func->($ccube)>=0)->sum > 0) { while(($func->($ccube)>=0)->sum->sclr > 0) {
$ccube *= 1.5; $ccube *= 1.5;
if($maxstep ++ > 30) { if($maxstep ++ > 30) {
die("Too far inside"); die("Too far inside");
} }
} }
# Now, we have a situation with a cube that has inside a I point # Now, we have a situation with a cube that has inside a I point
# and as corners O points. This does not guarantee that we have all # and as corners O points. This does not guarantee that we have all
# the surface but it's enough for now. # the surface but it's enough for now.
} }
skipping to change at line 110 skipping to change at line 110
# #
# XXX DOESN'T WORK # XXX DOESN'T WORK
sub polygonize { sub polygonize {
my($inv,$outv,$cubesize,$func) = @_; my($inv,$outv,$cubesize,$func) = @_;
barf "Must be positive" if $cubesize <= 0; barf "Must be positive" if $cubesize <= 0;
my $iv = $func->($inv); my $iv = $func->($inv);
my $ov = $func->($outv); my $ov = $func->($outv);
my $s; my $s;
# Find a close enough point to zero. # Find a close enough point to zero.
while(((sqrt(($iv-$ov))**2))->sum > $cubesize) { while(((sqrt(($iv-$ov))**2))->sum->sclr > $cubesize) {
my $s = $iv + $ov; $s /= 2; my $s = $iv + $ov; $s /= 2;
my $v = $func->($s); my $v = $func->($s);
$v->sum < 0 ? $v->sum->sclr < 0 ?
$ov = $s : $ov = $s :
$iv = $s; $iv = $s;
} }
# Correct the smaller distance to cubesize. # Correct the smaller distance to cubesize.
$iv = $ov + ($iv-$ov) * $cubesize / sqrt(($iv-$ov)**2) $iv = $ov + ($iv-$ov) * $cubesize / sqrt(($iv-$ov)**2)
# If it went outside, do it the other way around. # If it went outside, do it the other way around.
# if($func->($iv)->sum < 0) { # if($func->($iv)->sum->sclr < 0) {
# $ov = $iv + ($ov-$iv) * $cubesize / sqrt(($iv-$ov)**2) # $ov = $iv + ($ov-$iv) * $cubesize / sqrt(($iv-$ov)**2)
# } # }
# Now, |$iv-$ov| = $cubesize # Now, |$iv-$ov| = $cubesize
# Make the first cube # Make the first cube
# Then, start the cubes march. # Then, start the cubes march.
} }
# Cube coordinates. # Cube coordinates.
sub marchcubes { sub marchcubes {
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)