Methods
(static) add(v1, v2)
2d vector addition
Parameters:
Name | Type | Description |
---|---|---|
v1 |
float | Array.<float> | |
v2 |
Array.<float> |
Returns:
v1+v2
(static) det(v1, v2) → {float}
determinant of a column major 2x2 matrix
Parameters:
Name | Type | Description |
---|---|---|
v1 |
Array.<float> | first column |
v2 |
Array.<float> | second column |
Returns:
det([v1, v2])
- Type
- float
(static) dot(u, v) → {float}
computes the 2d dot product
Parameters:
Name | Type | Description |
---|---|---|
u |
Array.<float> | first vector |
v |
Array.<float> | second vector |
Returns:
(u dot v)
- Type
- float
(static) inv(v1, v2) → {Array.<Array.<float>>}
computes the inverse of a column major 2x2 matrix
Parameters:
Name | Type | Description |
---|---|---|
v1 |
Array.<float> | first column |
v2 |
Array.<float> | second column |
Returns:
the inverse matrix
- Type
- Array.<Array.<float>>
(static) linear_comb(v1, v2, a1, a2) → {Array.<float>}
calculate the linear combination of a1*v1+a2*v2, also known as the matrix vector product
Parameters:
Name | Type | Description |
---|---|---|
v1 |
Array.<float> | vector1 |
v2 |
Array.<float> | vector2 |
a1 |
float | scalar1 |
a2 |
float | scalar2 |
Returns:
the result of a1*v1+a2*v2
- Type
- Array.<float>
(static) normal_vec(vec) → {Array.<float>}
computes a orthogonal vector
Parameters:
Name | Type | Description |
---|---|---|
vec |
Array.<float> | a vector on which to calculate the orthogonal vector |
Returns:
a vector orthogonal of the original vector
- Type
- Array.<float>
(static) normalize(vec, final_length) → {Array.<float>}
normalizes a vector to a specific length
Parameters:
Name | Type | Description |
---|---|---|
vec |
Array.<float> | the vector you want to scale |
final_length |
float | the length you want the final vector to end up |
Returns:
the normalized vector
- Type
- Array.<float>
(static) proj(u, v) → {Array.<float>}
projection of the 2d vector u on to v
Parameters:
Name | Type | Description |
---|---|---|
u |
Array.<float> | first vector |
v |
Array.<float> | second vector (onto which to project the first) |
Returns:
the component of the first vector in the direction of the second
- Type
- Array.<float>
(static) scale(a, v) → {Array.<float>}
scale the 2d vector v by a scalar a
Parameters:
Name | Type | Description |
---|---|---|
a |
float | the scalar |
v |
Array.<float> | the vector |
Returns:
av
- Type
- Array.<float>
(static) sub(v1, v2)
2d vector subtraction
Parameters:
Name | Type | Description |
---|---|---|
v1 |
Array.<float> | |
v2 |
Array.<float> |
Returns:
v1-v2
(static) vec_len(vec) → {float}
compute the length of a 2d vector
Parameters:
Name | Type | Description |
---|---|---|
vec |
Array.<float> | a vector whose length we want to compute |
Returns:
the length of the vector
- Type
- float