c3d.vector

the vector library adds a bunch of common vector operations along with metatable methods to make them convinient. They are the same as https://tweaked.cc/module/vector.html by my lib is cleaner implementation.

new([x [, y [, z]]])returns a new vector object given the coordinates
methodsa bunch of operations you can do with the vector object (this does not show all but the most notable ones)
new([x [, y [, z]]])Source

returns a new vector object given the coordinates

Parameters

  1. x? number the x position of the vector
  2. y? number the y position of the vector
  3. z? number the z position of the vector

Returns

  1. vector the constructed vector object
methodsSource

a bunch of operations you can do with the vector object (this does not show all but the most notable ones)

cross(vec)gets the cross product between 2 vectors
dot(vec)finds the dont product of 2 vectors
normalize()normalizes a vector by dividing all of its axis by its lenght
scale([x [, y [, z]]])scales the vector with 3 given scales
translate([x [, y [, z]]])translates the vector with 3 given positions
rotate(...)rotates the vector with either a quaternion or euler angles
from_pitch_yaw(yaw, pitch)creates a 3D direction vector from pitch and yaw
from_yaw(yaw)creates a 2D direction vector from yaw
cross(vec)Source

gets the cross product between 2 vectors

Parameters

  1. vec vector the vector to get the cross product of along with this one

Returns

  1. vector The cross product of this and inputed vector
dot(vec)Source

finds the dont product of 2 vectors

Parameters

  1. vec vector the vector to get the dot product of along with this one

Returns

  1. number The dot product of the two vectors
normalize()Source

normalizes a vector by dividing all of its axis by its lenght

Returns

  1. vector The normalized vector
scale([x [, y [, z]]])Source

scales the vector with 3 given scales

Parameters

  1. x? number the x scale amount
  2. y? number the y scale amount
  3. z? number the z scale amount

Returns

  1. vector The scaled vector
translate([x [, y [, z]]])Source

translates the vector with 3 given positions

Parameters

  1. x? number the x positions amount
  2. y? number the y positions amount
  3. z? number the z positions amount

Returns

  1. vector The translated vector
rotate(...)Source

rotates the vector with either a quaternion or euler angles

Parameters

  1. dx number the x rotation of the vector
  2. dy number the y rotation of the vector
  3. dz number the z rotation of the vector

Or

  1. x number the quaternion vector x position
  2. y number the quaternion vector y position
  3. z number the quaternion vector z position
  4. w number the rotation along the quaternion vector

Returns

  1. vector The rotated vector
from_pitch_yaw(yaw, pitch)Source

creates a 3D direction vector from pitch and yaw

Parameters

  1. yaw number yaw to make the vector from
  2. pitch number pitch to make the vector from

Returns

  1. vector the created vector
from_yaw(yaw)Source

creates a 2D direction vector from yaw

Parameters

  1. yaw number yaw to make the vector from

Returns

  1. vector the created vector