Difference between revisions of "Vector (API)"
From ComputerCraft Wiki
(Undo revision 2101 by 91.121.27.33 (talk) yea removing that crap) |
Tomass1996 (Talk | contribs) (Error in info for mul function) |
||
| Line 27: | Line 27: | ||
|Subtracts vectorB to vectorA and returns the resulted vector. Can also be used by writing vectorA - vectorB. | |Subtracts vectorB to vectorA and returns the resulted vector. Can also be used by writing vectorA - vectorB. | ||
|- | |- | ||
| − | |vectorA:mul( | + | |vectorA:mul(n) |
| − | | | + | |Scalar multiplies vectorA with n and returns the resulted vector. Can also be used by writing vectorA * n. |
|- | |- | ||
|vectorA:dot(vectorB) | |vectorA:dot(vectorB) | ||
Revision as of 00:52, 2 September 2012
The vector API provides methods to create and manipulate vectors. An introduction to vectors can be found on Wikipedia.
| Static methods | |
|---|---|
| Method name | Description |
| vector.new(x, y, z) | Creates a vector. @param x, y, z the vector coordinates |
| Object methods | |
|---|---|
| Method name | Description |
| vectorA:add(vectorB) | Adds vectorB to vectorA and returns the resulted vector. Can also be used by writing vectorA + vectorB. |
| vectorA:sub(vectorB) | Subtracts vectorB to vectorA and returns the resulted vector. Can also be used by writing vectorA - vectorB. |
| vectorA:mul(n) | Scalar multiplies vectorA with n and returns the resulted vector. Can also be used by writing vectorA * n. |
| vectorA:dot(vectorB) | Returns the dot product of vectorA and vectorB. |
| vectorA:cross(vectorB) | Returns the vector which resulted in the cross product of vectorA and vectorB. |
| vectorA:length() | Returns the vector's length. |
| vectorA:normalize() | Normalizes the vector and returns the result as a new vector. |
| vectorA:round() | Rounds the vector coordinates to the nearest integers and returns the result as a new vector. |
| vectorA:tostring() | Returns a string representation of the vector in the form of "x,y,z". |