package AtomObject; use Exporter; use Common; @ISA = qw(Exporter Common); #公開したいサブルーチン @EXPORT = qw(); use strict; use Utils; sub new { my ($module) = @_; my $this = {}; bless $this; return $this; } sub DESTROY { my $this = shift; } sub SetLabel { my ($this,$Label) = @_; return $this->{Label} = $Label; } sub Label { my ($this) = @_; return $this->{'Label'}; } sub SetAtomName { my ($this,$AtomName) = @_; return $this->{'AtomName'} = $AtomName; } sub AtomName { my ($this) = @_; return $this->{'AtomName'};; } sub AtomNameOnly { my ($this, $DelPar) = @_; my $name = $this->{'AtomName'}; $name =~ s/^([^\d+-]*)([\d+-\.]*)/$1/; $name =~ s/\{[^\{\}]*\}//g if($DelPar); return $name; } sub Charge { my ($this) = @_; my $charge = $this->{'AtomName'}; $charge =~ s/^(\D*)(\d*)?([\+-]*)?/$2$3/; return $charge; } sub SetPosition { my ($this,$x,$y,$z) = @_; $this->{x} = Sci::Round($x, 8); $this->{y} = Sci::Round($y, 8); $this->{z} = Sci::Round($z, 8); return ($x,$y,$z); } sub Position { my ($this,$IsReduce01) = @_; if($IsReduce01) { my $x = &Round01($this->{'x'}); my $y = &Round01($this->{'y'}); my $z = &Round01($this->{'z'}); return (Utils::Reduce01($x), Utils::Reduce01($y), Utils::Reduce01($z) ); } return ($this->{x}, $this->{y}, $this->{z}); } sub SetForce { my ($this,$fx,$fy,$fz) = @_; $this->{fx} = Sci::Round($fx, 8); $this->{fy} = Sci::Round($fy, 8); $this->{fz} = Sci::Round($fz, 8); return ($fx, $fy, $fz); } sub Force { my ($this) = @_; return ($this->{fx}, $this->{fy}, $this->{fz}); } sub SetVelocity { my ($this,$vx,$vy,$vz) = @_; $this->{vx} = $vx; $this->{vy} = $vy; $this->{vz} = $vz; return ($vx, $vy, $vz); } sub Velocity { my ($this) = @_; my $vx = $this->{vx}; my $vy = $this->{vy}; my $vz = $this->{vz}; return ($vx, $vy, $vz); } sub Occupancy { my ($this) = @_; return ($this->{'Occupancy'}); } sub SetOccupancy { my ($this,$occ) = @_; $occ = 1.0 if(!defined $occ); return $this->{'Occupancy'} = $occ; } sub Round01 { my ($x) = @_; return 1.0 if(abs($x - 1.0) < 0.0002); return 0.0 if(abs($x) < 0.001); return $x; } 1;