#!/usr/bin/perl
package Point;
@ISA=qw(geometry);
1;
sub new {
 my $class = shift;
 my ($x,$y,$z) = @_;
 my $self = { 
 	x => $x, 
	y => $y, 
	z => $z
	};
 bless $self;
};

sub clone {
 my $self = shift;
 return Point->new ($self->x,$self->y,$self->z);
};
 
sub write {
 my $self = shift;
 print "$self->{x}, $self->{y}, $self->{z}\n";
};

sub x {
 my ($self, $x) = @_;
 $self->{x} = $x if defined $x;
 return $self->{x};
};
sub y {
 my ($self, $y) = @_;
 $self->{y} = $y if defined $y;
 return $self->{y};
};
sub z {
 my ($self, $z) = @_;
 $self->{z} = $z if defined $z;
 return $self->{z};
};

sub add {
 my ($self, $b) = @_;
 $self->{x} += $b->{x};
 $self->{y} += $b->{y};
 $self->{z} += $b->{z};
};

sub times {
 my ($self, $v) = @_;
 $self->{x} *= $v;
 $self->{y} *= $v;
 $self->{z} *= $v;
};

sub module {
 my $self = shift;
 return sqrt(Geometry::dot($self,$self));
};

sub makeUnit {
 my $self = shift;
 my $mod = $self->module();
 $self->times(1/$mod);
};
 
