NAME
Math::Vector - Abstract base class for vector classes
TREE
-+- Math::Vector
SEE ALSO
Math::Color, Math::ColorRGBA, Math::Image, Math::Vec2, Math::Vec3, Math::Rotation
SYNOPSIS
package Math::VecX;
use base 'Math::Vector';
use constant getDefaultValue => [ 0, 0 ];
1;
DESCRIPTION
OPERATORS
Summary
'!' => Returns true if the length of this vector is 0
'<' => Numerical gt. Compares the length of this vector with a vector or a scalar value.
'<=' => Numerical le. Compares the length of this vector with a vector or a scalar value.
'>' => Numerical lt. Compares the length of this vector with a vector or a scalar value.
'>=' => Numerical ge. Compares the length of this vector with a vector or a scalar value.
'<=>' => Numerical cmp. Compares the length of this vector with a vector or a scalar value.
'==' => Numerical eq. Performs a componentwise equation.
'!=' => Numerical ne. Performs a componentwise equation.
'lt' => Stringwise lt
'le' => Stringwise le
'gt' => Stringwise gt
'ge' => Stringwise ge
'cmp' => Stringwise cmp
'eq' => Stringwise eq
'ne' => Stringwise ne
'abs' => Performs a componentwise abs.
'""' => Returns a string representation of the vector.
METHODS
new
my $v = new Math::VecX;
my $v2 = new Math::VecX(1,2);
my @v3 = @$v;
If you call new() with a reference to an array, it will be used as reference.
my $v3 = new Math::VecX([1,2]);
copy
Makes a copy
$v2 = $v1->copy;
getArray
Returns the reference to the array.
$a = $v1->getArray;
setValue(x,y,z)
Sets the value of the vector
$v1->setValue(1,2);
getValue
Returns the value of the vector (x, y) as a 2 components array.
@v = $v1->getValue;
setValue(x,y,z)
Sets the value of the vector
$v1->setValue(1,2);
abs()
Performs a componentwise abs. This is used to overload the 'abs' operator.
rotate(n)
Performs a componentwise rotation.
$v = $vec->rotate(1);
$v = $vec->rotate(-2);
sig
Performs a componentwise sig.
$v = new Math::VecX(-4, 5);
$v = $VecX->sig;
printf $v; # -1 1
sum
Returns the sum of the components.
$v = new Math::VecX(-8, 2);
$s = $VecX->sum;
printf $s; # -6
normalize
$v = $v1->normalize;
toString
Returns a string representation of the vector. This is used to overload the '""' operator, so that vector may be freely interpolated in strings.
my $q = new Math::VecX(1,2);
print $q->toString; # "1 2"
print "$q"; # "1 2"
BUGS & SUGGESTIONS
If you run into a miscalculation please drop the author a note.
ARRANGED BY
Holger Seelig holger.seelig@yahoo.de
COPYRIGHT
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.