CmUtils::Vector

Provides simple 3d vector functionality including, addition, subtraction, scalar multiplication, cross product, norm, plot(print) and converting to a perl list.

VERSION

1.00 (23 October 2002)

new(array)

Constructor to create a new Vector object. Takes an array of 3 numbers to populate the vector coordinates.

    $v1 = new CmUtils::Vector( @array );
    $v2 = new CmUtils::Vector( (1,2,3) );

list()

Returns the vector components as an array

    @array = $v1->list();

myprint()

Evaluates the vector in a string context;

    @v1->myprint();

myadd

Implementation of vector addition for overloaded operator +

mymult

Implementation of vector scalar multiplication for overloaded operator *

mydiv

Implementation of vector scalar division for overloaded operator /

mysub

Implementation of vector subtraction for overloaded operator -

crossp($v1,$v2)

Returns the vector cross product of two vectors

    $v3 = crossp($v1,$v2);

dotp($v1,$v2)

Returns the vector dot product of two vectors

    $v3 = dotp($v1,$v2);

norm($v1)

Returns the norm of a vector

    $norm = norm($v1);

length()

Returns the length of a vector

    $length = $v1->length;

plot()

Prints out the vector components, useful in debugging

    @v1->plot();