#!/usr/bin/perl # the above is the standard linux/unix path for perl: change if your computer is nonstandard sub print_help{ print STDERR <0 or die "Invalid lattice parameter $a\n"; next; } if($p eq "-t"){ # help $thresh=shift(@ARGV)+0; $thresh<=0 && $thresh>= -1 or print STDERR "xyz_color_lattice: Valid threshold had better be in the [-1 , 0] range\n"; next; } if($p eq "-h"){ # help print_help; die "\n"; } print_help; die "invalid option $p\n"; } if($#inputfiles<0){ push(@inputfiles,"-"); # adds stdio for lack of arguments } $#inputfiles<2 or die "Can process 1 file only!\n"; $filename=$inputfiles[0]; $count=0; $totp=0; $frames=0; $nold=-99999; open(INPUT, $filename) || die "Cannot open $filename\n"; while(){ s/^\s*//; # remove leading spaces @li = split('\s+'); if($#li==0 && $li[0]+0==$li[0] && $count!=1){ $n=$li[0]+0; print; $frames++; $count=0; }elsif($count==1){ print; }else{ $x=$li[1]; $y=$li[2]; # $W= -0.5-0.25*(cos(2*$PI*$x/$a) + cos(2*$PI*$y/$a) ); # square version $W= -2. / 9. * (1.5 +2.*cos(2*$PI*$x/$a) *cos(2.*$PI*$y/(sqrt(3.)*$a)) + cos(4*$PI*$y/(sqrt(3.)*$a)) ); if($W>$thresh){ print "Li $li[1] $li[2] $li[3]\n"; }else{ print; } } $count++; } close(INPUT);