Vector
Manipulate 3D vectors
PhilipRBrenan@yahoo.com, 2004, Perl licence
Synopsis
Example t/vector.t
#_ Vector _____________________________________________________________
# Test 3d vectors
# philiprbrenan@yahoo.com, 2004, Perl License
#______________________________________________________________________
use Math::Zap::Vector vector=>'v', units=>'u';
use Test::Simple tests=>7;
my ($x, $y, $z) = u();
ok(!$x == 1);
ok(2*$x+3*$y+4*$z == v( 2, 3, 4));
ok(-$x-$y-$z == v(-1, -1, -1));
ok((2*$x+3*$y+4*$z) + (-$x-$y-$z) == v( 1, 2, 3));
ok((2*$x+3*$y+4*$z) * (-$x-$y-$z) == -9);
ok($x*2 == v( 2, 0, 0));
ok($y/2 == v( 0, 0.5, 0));
Description
Manipulate 3 dimensional vectors via operators.
Constructors
new
Create a vector from numbers
units
Unit vectors
Methods
check
Check its a vector
is
Test its a vector
accuracy
Get/Set accuracy for comparisons
round
Round: round to nearest integer if within accuracy of that integer
x,y,z
x,y,z components of vector
clone
Create a vector from another vector
length
Length of a vector
Print vector
norm
Normalize vector
dot
Dot product
angle
Angle between two vectors
cross
Cross product
add
Add vectors
subtract
Subtract vectors
multiply
Vector times a scalar
divide
Vector divided by a non zero scalar
equals
Equals to within accuracy
Operator Overloads
Operator overloads
Add operator
Add operator, see "add"
Subtract Operator
Subtract operator.
Multiply Operator
Multiply operator, see "multiply"
Divide Operator
Divide operator, see "divide"
Cross Operator
Cross operator, see "cross"
Angle Operator
Angle operator, see "angle"
Equals Operator
Equals operator, see "equals"
Print Operator
Print a vector, see "print"
Export Definitions
Export "vector", "units", "check", "is"
Credits
Author
philiprbrenan@yahoo.com
Copyright
philiprbrenan@yahoo.com, 2004
License
Perl License.