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

Class: Math_Vector

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

Class Overview


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


Author(s):

Version:

  • 1.0

Methods


Child classes:

Math_Vector2
2D Vector class Originally this class was part of NumPHP (Numeric PHP package)
Math_Vector3
3D vector class Originally this class was part of NumPHP (Numeric PHP package)

Inherited Variables

Inherited Methods


Class Details

[line 36]
General Vector class Originally this class was part of NumPHP (Numeric PHP package)


[ Top ]


Method Detail

Math_Vector (Constructor)   [line 54]

object Math_Vector Math_Vector( [optional $data = null])

Constructor for Math_Vector

Parameters:

optional   $data   —  array|Math_Tuple|Math_Vector $data a Math_Tuple object, a Math_Vetctor object, or an array of numeric data

[ Top ]

cartesianDistance   [line 290]

float cartesianDistance( object $vector)

Returns the cartesian distance to another vector
  • Return: on success, a PEAR_Error object on failure
  • Access: public

Parameters:

object   $vector   —  Math_Vector object

[ Top ]

chessboardDistance   [line 338]

float chessboardDistance( object $vector)

Returns the Chessboard distance to another vector Definition: chessboard dist. = max(|x1 - x2|, |y1 - y2|, ...)
  • Return: on success, a PEAR_Error object on failure
  • Access: public

Parameters:

object   $vector   —  Math_Vector object

[ Top ]

conjugate   [line 206]

void conjugate( )

Conjugates the vector. Alias of reverse.

[ Top ]

distance   [line 267]

float distance( object $vector, [string $type = 'cartesian'])

Returns the distance to another vector
  • Return: on success, a PEAR_Error object on failure
  • Access: public

Parameters:

object   $vector   —  Math_Vector object
string   $type   —  distance type: cartesian (default), manhattan or chessboard

[ Top ]

get   [line 254]

mixed get( integer $i)

Gets the value of a element
  • Return: the element value (numeric) on success, a PEAR_Error object otherwise
  • Access: public

Parameters:

integer   $i   —  the index of the element

[ Top ]

getData   [line 90]

array|PEAR_Error getData( )

Returns an array of numbers
  • Return: a numeric array on success, a PEAR_Error otherwise
  • Access: public

[ Top ]

getTuple   [line 169]

object Math_Tuple getTuple( )

returns the Math_Tuple object corresponding to the vector
  • Access: public

[ Top ]

isValid   [line 105]

boolean isValid( )

Checks if the vector has been correctly initialized
  • Access: public

[ Top ]

length   [line 132]

float length( )

Returns the length of the vector
  • Access: public

[ Top ]

lengthSquared   [line 117]

float lengthSquared( )

Returns the square of the vector's length
  • Access: public

[ Top ]

magnitude   [line 143]

float magnitude( )

Returns the magnitude of the vector. Alias of length
  • Access: public

[ Top ]

manhattanDistance   [line 314]

float manhattanDistance( object $vector)

Returns the Manhattan (aka City) distance to another vector Definition: manhattan dist. = |x1 - x2| + |y1 - y2| + ...
  • Return: on success, a PEAR_Error object on failure
  • Access: public

Parameters:

object   $vector   —  Math_Vector object

[ Top ]

normalize   [line 154]

void normalize( )

Normalizes the vector, converting it to a unit vector
  • Access: public

[ Top ]

reverse   [line 191]

void reverse( )

Reverses the direction of the vector negating each element
  • Access: public

[ Top ]

scale   [line 218]

mixed scale( float $f)

Scales the vector elements by the given factor
  • Return: void on success, a PEAR_Error object otherwise
  • Access: public

Parameters:

float   $f   —  scaling factor

[ Top ]

set   [line 238]

mixed set( integer $i, numeric $value)

Sets the value of a element
  • Return: true on success, a PEAR_Error object otherwise
  • Access: public

Parameters:

integer   $i   —  the index of the element
numeric   $value   —  the value to assign to the element

[ Top ]

setData   [line 68]

boolean|PEAR_Error setData( array|Math_Tuple|Math_Vector $data)

Initializes the vector
  • Return: TRUE on success, a PEAR_Error otherwise
  • Access: public

Parameters:

array|Math_Tuple|Math_Vector   $data   —  a Math_Tuple object, a Math_Vetctor object, or an array of numeric data

[ Top ]

size   [line 180]

float size( )

Returns the number of elements (dimensions) of the vector
  • Access: public

[ Top ]

toString   [line 361]

string toString( )

Returns a simple string representation of the vector
  • Access: public

[ Top ]


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