Graphmath.Vec2
This is the 2D mathematics library for graphmath.
Summary
add_vec2(a, b) |
|
compare_vec2(list1, list2, l) |
|
create_vec2() |
|
create_vec2(vec) | |
dot_vec2(list1, list2) |
|
length_manhattan_vec2(list1) |
|
length_squared_vec2(list1) |
|
length_vec2(list1) |
|
lerp_vec2(list1, list2, t) |
|
normalize_vec2(list1) |
|
perp_prod_vec2(list1, list2) |
|
project_vec2(list1, list2) |
|
rotate_vec2(list1, theta) |
|
scale_vec2(vec, scale) |
|
subtract_vec2(list1, list2) |
|
Functions
Specs:
- add_vec2([float], [float]) :: [float]
`add_vec2` is used to add a vec2 to another vec2.
It takes two vec2s and returns a vec2 which is the element-wise sum of those lists.
Specs:
- compare_vec2([float], [float], float) :: boolean
`compare_vec2` is used to check whether or not two vectors are within a length of each other.
Specs:
- create_vec2 :: [float]
`create_vec2` is used to create a 2d vector.
It takes a list of numbers and converts it into an array of form [x,y].
Specs:
- dot_vec2([float], [float]) :: float
`dot_vec2` is used to find the inner product (dot product) of one vec2 and another.
Passing it two vec2s will cause it to return the inner product of those two vec2s.
Specs:
- length_manhattan_vec2([float]) :: float
`length_manhatten_vec2` is used to find the Manhattan (L1 norm) length of a vector.
The Manhattan length is simply the sum of the components.
Specs:
- length_squared_vec2([float]) :: float
`length_squared_vec2` is used to find the square of the length of a vector.
In many cases, this is sufficient for comparisions and avaoids a sqrt.
Specs:
- length_vec2([float]) :: float
`length_vec2` is used to find the length (L2 norm) of a vector.
The length is the square root of the sum of the squares.
Specs:
- lerp_vec2([float], [float], float) :: [float]
`lerp_vec2` is used to linearly interpolate between two given vectors.
The interpolant is on the domain [0,1]. Behavior outside of that is undefined.
Specs:
- normalize_vec2([float]) :: [float]
`normalize_vec2` is used to find the unit vector with the same direction as the supplied vector.
This is done by dividing each component by the vector's magnitude.
Specs:
- perp_prod_vec2([float], [float]) :: float
`perp_prod_vec2` is used to find the perpindicular product of two vec2s.
The perpindicular product is the magnitude of the cross-product between the two vectors.
Specs:
- project_vec2([float], [float]) :: [float]
`project_vec2` projects one vector onto another, and returns the resulting image.
Specs:
- rotate_vec2([float], float) :: [float]
`rotate_vec2` is used to rotate a vec CCW about the +Z axis a given number of radians.
Specs:
- scale_vec2([float], float) :: [float]
- scale_vec2([float], [float]) :: [float]
`scale_vec2` is used to perform a scaling on a vec2.
Passing it a single number will cause all elements of the vec2 to be multipled by that number.
Passing it a vec2 will cause each element of to be multiplied by the corresponding element of the scale vec2.