package Manticore::Geometry::Point; use strict; use warnings; sub new { my (undef, $x, $y) = @_; return bless [$x,$y] } # parse a string and return as vector sub fromText { my (undef,$text)=@_; if($text=~m#^([0-9\.]+),([0-9\.]+)$#) { return bless [$1,$2] } else { return { error=> "Parse error: Not a vector" } } } # difference between two points; returns a vector sub diff { my ($self, $other) = @_; return Manticore::Geometry::Vector->new($other->[0]-$self->[0], $other->[1]-$self->[1]); } 1;