# 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 |
---|---|

methods | a 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

- x? number the
`x`

position of the vector - y? number the
`y`

position of the vector - z? number the
`z`

position of the vector

### Returns

- vector the constructed vector object

- x? number the
- 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

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

### Returns

- vector The cross product of this and inputed vector

- dot(vec)Source
finds the dont product of 2 vectors

### Parameters

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

### Returns

- number The dot product of the two vectors

- normalize()Source
normalizes a vector by dividing all of its axis by its lenght

### Returns

- vector The normalized vector

- scale([x [, y [, z]]])Source
scales the vector with 3 given scales

### Parameters

- x? number the
`x`

scale amount - y? number the
`y`

scale amount - z? number the
`z`

scale amount

### Returns

- vector The scaled vector

- x? number the
- translate([x [, y [, z]]])Source
translates the vector with 3 given positions

### Parameters

- x? number the
`x`

positions amount - y? number the
`y`

positions amount - z? number the
`z`

positions amount

### Returns

- vector The translated vector

- x? number the
- rotate(...)Source
rotates the vector with either a quaternion or euler angles

### Parameters

- dx number the
`x`

rotation of the vector - dy number the
`y`

rotation of the vector - dz number the
`z`

rotation of the vector

#### Or

- x number the quaternion vector
`x`

position - y number the quaternion vector
`y`

position - z number the quaternion vector
`z`

position - w number the rotation along the quaternion vector

### Returns

- vector The rotated vector

- dx number the
- from_pitch_yaw(yaw, pitch)Source
creates a 3D direction vector from pitch and yaw

### Parameters

- yaw number yaw to make the vector from
- pitch number pitch to make the vector from

### Returns

- vector the created vector

- from_yaw(yaw)Source
creates a 2D direction vector from yaw

### Parameters

- yaw number yaw to make the vector from

### Returns

- vector the created vector