Mercurial > hg > Game > Cerium
view old/tmp/outer.pl @ 1616:05d449e7b9f8 draft
remove set_NDRange
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 14 May 2013 13:40:50 +0900 |
parents | 7c051c101642 |
children |
line wrap: on
line source
#!/usr/bin/perl # fix Cerium xml normal vector my $i = -1; my (@x,@y,@z); my @cord; my $fix = 1; sub v { print "$x[0] $y[0] $z[0]\n"; print "$x[1] $y[1] $z[1]\n"; print "$x[2] $y[2] $z[2]\n"; } sub outer { my ($ax,$ay,$az) = ( $x[1]-$x[0], $y[1]-$y[0], $z[1]-$z[0], ); my ($bx,$by,$bz) = ( $x[2]-$x[0], $y[2]-$y[0], $z[2]-$z[0], ); my ($ox,$oy,$oz) = ( $ay*$bz - $az*$by, -$ax*$bz + $az*$bx, $ax*$by - $ay*$bx, ); my($r) = sqrt($ox*$ox+$oy*$oy+$oz*$oz); ($ox,$oy,$oz) = ($ox/$r,$oy/$r,$oz/$r); push(@cord, [$ox,$oy,$oz]); # print " $ox $oy $oz\n"; } while(<>) { if (! $fix) { if (/<sur/) { print; next; } } if (/<normal/) { $i= -2; print if ($fix); next; } if (/<\/normal/) { $i = -1; print if ($fix); next; } if ( $i < -1) { if ($i== -4) { my $cord = shift(@cord); if ($fix) { print " $cord->[0] $cord->[1] $cord->[2] \n"; print " $cord->[0] $cord->[1] $cord->[2] \n"; print " $cord->[0] $cord->[1] $cord->[2] \n"; } else { print "outer $i $cord->[0] $cord->[1] $cord->[2] \n"; print ; } $i = -2; } else { $i--; } next; } print if ($fix); if (/<\/coord/) { $i = -1; next; } if (/<coord/) { @cord = (); $i=0; next; } if ($i<0) { next; } if (/([-]*[.\d]+)\s+([-]*[.\d]+)\s+([-]*[.\d]+)/) { ($x[$i],$y[$i],$z[$i]) = ($1,$2,$3); # print "$i $_"; if ($i==2) { &outer; $i = 0; next; } $i++; } else { $i = -1; } } # end