Graphmath.Vec3

This is the 3D mathematics library for graphmath.

Summary

add(list1, list2)

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
compare(list1, list2, l)

compare is used to check whether or not two vectors are within a length of each other

create()

create is used to create a 3d vector

create(vec)
create(x, y, z)
cross(list1, list2)

cross is used to find the cross product of one vec3 and another

dot(list1, list2)

dot is used to find the inner product (dot product) of one vec3 and another

length(list1)

length is used to find the length (L2 norm) of a vector

length_manhattan(list1)

length_manhatten is used to find the Manhattan (L1 norm) length of a vector

length_squared(list1)

length_squared is used to find the square of the length of a vector

lerp(list1, list2, t)

lerp is used to linearly interpolate between two given vectors

normalize(list1)

normalize is used to find the unit vector with the same direction as the supplied vector

scale(vec, scale)

scale is used to perform a scaling on a vec3

subtract(list1, list2)

subtract is used to subtract a vec3 from another vec2.

It takes two vec3s and returns the difference of the two

Functions

add(list1, list2)

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.
compare(list1, list2, l)

Specs:

  • compare([float], [float], float) :: boolean
`compare` is used to check whether or not two vectors are within a length of each other.
create()

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].

create(vec)

Specs:

  • create([float]) :: [float]
create(x, y, z)

Specs:

  • create(float, float, float) :: [float]
cross(list1, list2)

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.
dot(list1, list2)

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.
length(list1)

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.
length_manhattan(list1)

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.
length_squared(list1)

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.
lerp(list1, list2, t)

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.
normalize(list1)

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.
scale(vec, scale)

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.
subtract(list1, list2)

Specs:

  • subtract([float], [float]) :: [float]
`subtract` is used to subtract a vec3 from another vec2.
It takes two vec3s and returns the difference of the two.