|
MathWorx | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--Vector
Defined in Vector.js
Field Summary | |
Array |
components
the components of the Vector |
Integer |
n
the dimension of the array (length of components array) |
<static> <final> Vector |
i
The unit vector [1,0,0] |
<static> <final> Vector |
j
The unit vector [0,1,0] |
<static> <final> Vector |
k
The unit vector [0,0,1] |
Constructor Summary | |
Vector(<Object> elements)
Constructor function. |
Method Summary | |
Vector
|
add(<Vector> vec)
Adds a vector to the supplied vector. |
void
|
addElement(<Number> el)
Adds a new element to the vector and updates the dimension. |
Number
|
angleBetween(<Vector> vec)
Finds and returns the angle between two vectors. |
Vector
|
cross(<Vector> vec)
Computes the cross product of two 3-dimensional vectors. |
Integer
|
dimension(<Integer> n)
Sets and/or returns the dimension of the vector. |
Number
|
distanceFrom(<Object> obj)
Returns the distance between the vector and an object, as if the vector were a point in its n-space. |
Number
|
dot(<Vector> vec)
Returns the scalar dot product of this vector and the supplied vector. |
Array
|
elements(<Array> els)
Method for setting and getting the elements of a vector. |
Boolean
|
equalTo(<Vector> vec)
Tests to see if two vectors are equal to each other. |
Number
|
get(<Integer> index)
Gets the component of the vector at index. |
Number
|
getLength()
Returns the length of the vector by modulus definition. |
Number
|
indexOf(<Number> x)
Returns the first occurence of x in the vector. |
Boolean
|
isAntiParallel(<Vector> vec)
Tests if two vectors are antiparallel. |
Boolean
|
isParallel(<Vector> vec)
Tests if two vectors are parallel. |
Boolean
|
isPerpendicular(<Vector> vec)
Tests if two vectors are perpendicular. |
Boolean
|
linearlyDependent(<Vector> vec)
Tests to see if 2 vectors are linearly dependent. |
Boolean
|
linearlyIndependent(<Vector> vec)
Tests to see if 2 vectors are linearly independent from each other. |
Vector
|
make3D()
Makes a copy of the given vector in 3 dimensions. |
Vector
|
map(<Function> func)
Maps the vector to a new vector by the supplied function. |
Number
|
max()
Finds and returns the element with the largest absolute value. |
Vector
|
multiplyBy(<Number> k)
Multiplies a vector by a scalar k. |
Object
|
negative()
Returns a negative copy of the Vector (or point). |
Vector
|
normalize()
Normalizes the vector and returns the new unit vector. |
Object
|
reflectionIn(<Object> obj)
Reflects the Vector or point2D/3D in the given point, line, or plane |
Vector
|
resolute(<Vector> vec)
Projects one Vector onto another. |
Vector
|
round()
Rounds all the elements of the vector and returns the copy. |
Object
|
snapTo(<Number> val)
Sets all values within range of Zero (set in easyload.js) to val. |
Vector
|
subtract(<Vector> vec)
Subtracts a vector to the supplied vector. |
Matrix
|
toColumnMatrix()
Converts a Vector into a 1-column matrix. |
void
|
toEach(<Function> func)
Performs a supplied function on every element of the vector. |
Object
|
toPoint()
Converts a Vector to a point object of appropriate dimension in homogeneous coordinates. |
Matrix
|
toRowMatrix()
Converts a Vector into a 1-row matrix. |
String
|
toString()
Returns a string representation of the vector. |
<static> Vector
|
random(<Integer> n, <Number> max)
Creates and returns a new vector with n random elements less than or equal to max. |
<static> Vector
|
zero(<Integer> n)
Creates and returns a new vector of dimension n with all 0 components. |
Field Detail |
Array components
Integer n
<static> <final> Vector i
<static> <final> Vector j
<static> <final> Vector k
Constructor Detail |
Vector(<Object> elements)
elements
- Array to become the components of the Vector; if a Vector, will clone the vector into a new one
Method Detail |
Vector add(<Vector> vec)
vec
- the vector to be added.
void addElement(<Number> el)
el
- the number to add to the vector
Number angleBetween(<Vector> vec)
vec
- the vector from which to find the angle
Vector cross(<Vector> vec)
vec
- the vector with which to take the cross product
Integer dimension(<Integer> n)
n
- (optional) the dimension to set the array. If n > current dimension, 0s added as all new components; if n < current dimension, all components greater than that dimension are deleted.
Number distanceFrom(<Object> obj)
obj
- the object from which to get the distance
Number dot(<Vector> vec)
vec
- the vector with which to compute the dot product
Array elements(<Array> els)
els
- (Optional) if supplied, will set the vector's elements to els.
Boolean equalTo(<Vector> vec)
vec
- - the vector to compare to
Number get(<Integer> index)
index
- the index for which you want the component
Number getLength()
Number indexOf(<Number> x)
x
- the element to search for
Boolean isAntiParallel(<Vector> vec)
vec
- the vector to compare
Boolean isParallel(<Vector> vec)
vec
- the vector to compare
Boolean isPerpendicular(<Vector> vec)
vec
- - the vector to compare
Boolean linearlyDependent(<Vector> vec)
vec
- the vector to compare with
Boolean linearlyIndependent(<Vector> vec)
vec
- the vector to test for independence
Vector make3D()
Vector map(<Function> func)
func
- the mapping function
Number max()
Vector multiplyBy(<Number> k)
k
- the scalar by which to multiply the vector
Object negative()
Vector normalize()
Object reflectionIn(<Object> obj)
obj
- the Line, Plane, or Vector/point2D/3D in which to reflect this
Vector resolute(<Vector> vec)
vec
- (or point2D/3D object) the vector onto which to project this vector
Vector round()
Object snapTo(<Number> val)
val
- the number to snap the vector to
Vector subtract(<Vector> vec)
vec
- the vector to be subtracted.
Matrix toColumnMatrix()
void toEach(<Function> func)
func
- the function to perform on each element
Object toPoint()
Matrix toRowMatrix()
String toString()
<static> Vector random(<Integer> n, <Number> max)
n
- the number of components the vector should be
max
- (Optional) the maximum value the elements can be; if not specified, values will be in rand [0,1)
<static> Vector zero(<Integer> n)
n
- the dimension of the new zero vector
|
MathWorx | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |