# HG changeset patch # User yutaka@henri.cr.ie.u-ryukyu.ac.jp # Date 1258012808 -32400 # Node ID b0fb0272191c72bbcb4ee17c8c934dd0d60e98b5 # Parent 2cfbb36e221a13b48494298e0117ac3ac8e475ea add revers.pl diff -r 2cfbb36e221a -r b0fb0272191c old/tmp/revers.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/tmp/revers.pl Thu Nov 12 17:00:08 2009 +0900 @@ -0,0 +1,124 @@ +#!/usr/bin/perl + +# fix Cerium xml normal vector + +my $i = -1; +my (@x,@y,@z); +my @cord; +my $flag = 0; +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"; +} + +if (@ARGV != 2) { + die "Usage : objectname filename\n"; +} + +my ($object, $file) = @ARGV; +open(IN, $file); + +while() { + if (! $fix) { + if (/[0] = -$cord->[0]; + $cord->[1] = -$cord->[1]; + $cord->[2] = -$cord->[2]; + } + + 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 (/