Graphmath.Vec3
This is the 3D mathematics library for graphmath.
Summary
add(list1, list2) |
|
compare(list1, list2, l) |
|
create() |
|
create(vec) | |
create(x, y, z) | |
cross(list1, list2) |
|
dot(list1, list2) |
|
length(list1) |
|
length_manhattan(list1) |
|
length_squared(list1) |
|
lerp(list1, list2, t) |
|
normalize(list1) |
|
scale(vec, scale) |
|
subtract(list1, list2) |
|
Functions
Specs:
- add([float], [float]) :: [float]
`add` is used to add a vec3 to another vec3.
It takes two vec3s and returns a vec3 which is the element-wise sum of those lists.
Specs:
- compare([float], [float], float) :: boolean
`compare` is used to check whether or not two vectors are within a length of each other.
Specs:
- create :: [float]
create
is used to create a 3d vector.
It takes a list of numbers and converts it into an array of form [x,y,z].
Specs:
- cross([float], [float]) :: [float]
`cross` is used to find the cross product of one vec3 and another.
Passing it two vec3s will cause it to return the cross product of the frist with the second.
Specs:
- dot([float], [float]) :: float
`dot` is used to find the inner product (dot product) of one vec3 and another.
Passing it two vec3s will cause it to return the inner product of those two vec3s.
Specs:
- length([float]) :: float
`length` is used to find the length (L2 norm) of a vector.
The length is the square root of the sum of the squares.
Specs:
- length_manhattan([float]) :: float
`length_manhatten` 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([float]) :: float
`length_squared` 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:
- lerp([float], [float], float) :: [float]
`lerp` 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([float]) :: [float]
`normalize` 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:
- scale([float], float) :: [float]
- scale([float], [float]) :: [float]
`scale` is used to perform a scaling on a vec3.
Passing it a single number will cause all elements of the vec2 to be multipled by that number.
Passing it a vec3 will cause each element of to be multiplied by the corresponding element of the scale vec3.