Math_Vector [ class tree: Math_Vector ] [ index: Math_Vector ] [ all elements ]

# Class: Math_Vector2

Source Location: /Math_Vector-0.7.0/Math/Vector2.php

### Class Overview

```Math_Vector
|
--Math_Vector2```

2D Vector class Originally this class was part of NumPHP (Numeric PHP package)

• 1.0

### Inherited Methods

#### Class: Math_Vector

Math_Vector::Math_Vector()
Constructor for Math_Vector
Math_Vector::cartesianDistance()
Returns the cartesian distance to another vector
Math_Vector::chessboardDistance()
Returns the Chessboard distance to another vector Definition: chessboard dist. = max(|x1 - x2|, |y1 - y2|, ...)
Math_Vector::conjugate()
Conjugates the vector. Alias of reverse.
Math_Vector::distance()
Returns the distance to another vector
Math_Vector::get()
Gets the value of a element
Math_Vector::getData()
Returns an array of numbers
Math_Vector::getTuple()
returns the Math_Tuple object corresponding to the vector
Math_Vector::isValid()
Checks if the vector has been correctly initialized
Math_Vector::length()
Returns the length of the vector
Math_Vector::lengthSquared()
Returns the square of the vector's length
Math_Vector::magnitude()
Returns the magnitude of the vector. Alias of length
Math_Vector::manhattanDistance()
Returns the Manhattan (aka City) distance to another vector Definition: manhattan dist. = |x1 - x2| + |y1 - y2| + ...
Math_Vector::normalize()
Normalizes the vector, converting it to a unit vector
Math_Vector::reverse()
Reverses the direction of the vector negating each element
Math_Vector::scale()
Scales the vector elements by the given factor
Math_Vector::set()
Sets the value of a element
Math_Vector::setData()
Initializes the vector
Math_Vector::size()
Returns the number of elements (dimensions) of the vector
Math_Vector::toString()
Returns a simple string representation of the vector

### Class Details

[line 33]
2D Vector class Originally this class was part of NumPHP (Numeric PHP package)

[ Top ]

### Math_Vector2 (Constructor)   [line 41]

 ```Math_Vector2 Math_Vector2( mixed \$arg)```

Constructor for Math_Vector2
• Access: public

#### Parameters:

 mixed \$arg — an array of values, a Math_Tuple object or a Math_Vector2 object

[ Top ]

### getX   [line 61]

 ```numeric getX( )```

Returns the X component of the vector
• Access: public

[ Top ]

### getY   [line 84]

 ```numeric getY( )```

Returns the Y component of the vector
• Access: public

[ Top ]

### setX   [line 73]

 ```mixed setX( numeric \$val)```

Sets the X component of the vector
• Return: true on success, PEAR_Error object otherwise
• Access: public

#### Parameters:

 numeric \$val — the value for the Y component

[ Top ]

### setY   [line 96]

 ```mixed setY( numeric \$val)```

Sets the Y component of the vector
• Return: true on success, PEAR_Error object otherwise
• Access: public

#### Parameters:

 numeric \$val — the value for the Y component

[ Top ]

Documentation generated on Mon, 11 Mar 2019 15:39:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.