Manipulate 2D vectors
PhilipRBrenan@yahoo.com, 2004, Perl License
Example t/vector2.t
#_ Vector _____________________________________________________________ # Test 2d vectors # philiprbrenan@yahoo.com, 2004, Perl License #______________________________________________________________________ use Math::Zap::Vector2 vector2=>v, units=>u; use Test::Simple tests=>7; my ($x, $y) = u(); ok(!$x == 1); ok(2*$x+3*$y == v( 2, 3)); ok(-$x-$y == v(-1, -1)); ok((2*$x+3*$y) + (-$x-$y) == v( 1, 2)); ok((2*$x+3*$y) * (-$x-$y) == -5); ok($x*2 == v( 2, 0)); ok($y/2 == v( 0, 0.5));
Create a vector from numbers
Create a vector from numbers - synonym for "new"
Unit vectors
Check its a vector
Test its a vector
Get/Set accuracy for comparisons
Round: round to nearest integer if within accuracy of that integer
x,y components of vector
Create a vector from another vector
Length of a vector
Print vector
Normalize vector
At right angles
Dot product
Angle between two vectors
Add vectors
Subtract vectors
Vector times a scalar
Vector divided by a non zero scalar
Equals to within accuracy
# Operator overloads
Add operator.
Subtract operator.
Multiply operator.
Divide operator.
Angle between two vectors.
Equals operator.
Print a vector.
Export "vector2", "units", "check", "is"
philiprbrenan@yahoo.com
philiprbrenan@yahoo.com, 2004
Perl License.
To install Math::Zap::Draw, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::Zap::Draw
CPAN shell
perl -MCPAN -e shell install Math::Zap::Draw
For more information on module installation, please visit the detailed CPAN module installation guide.