# Vector2

Manipulate 2D vectors

## Synopsis

Example t/vector2.t

`````` #_ Vector _____________________________________________________________
# Test 2d vectors
#______________________________________________________________________

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));
``````

## Description

Manipulate 2D vectors

## Constructors

### new

Create a vector from numbers

### vector2

Create a vector from numbers - synonym for "new"

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

### components

x,y components of vector

### clone

Create a vector from another vector

### length

Length of a vector

Print vector

Normalize vector

At right angles

Dot product

### angle

Angle between two vectors

Subtract vectors

### multiply

Vector times a scalar

### divide

Vector divided by a non zero scalar

### equals

Equals to within accuracy

## Operators

### subtract

Subtract operator.

### multiply

Multiply operator.

Divide operator.

### angle

Angle between two vectors.

Equals operator.

Print a vector.

## Exports

Export "vector2", "units", "check", "is"

## Credits

### Author

philiprbrenan@yahoo.com

philiprbrenan@yahoo.com, 2004