Difference between revisions of "Vector (API)"
From ComputerCraft Wiki
Line 18: | Line 18: | ||
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:sub]]([[Vector (API)|vector]] vectorB)</td> | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:sub]]([[Vector (API)|vector]] vectorB)</td> | ||
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Subtracts vectorB from vectorA and returns the | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Subtracts vectorB from vectorA and returns the resulting vector. Can also be used by writing vectorA - vectorB.</td></tr> |
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:mul]]([[float (type)|float]] n)</td> | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:mul]]([[float (type)|float]] n)</td> | ||
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Scalar multiplies vectorA with n and returns the | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Scalar multiplies vectorA with n and returns the resulting vector. Can also be used by writing vectorA * n.</td></tr> |
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:dot]]([[Vector (API)|vector]] vectorB)</td> | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:dot]]([[Vector (API)|vector]] vectorB)</td> |
Revision as of 11:57, 23 February 2013
This page needs some serious TLC, stat! Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: Needs function pages, some parameters missing types Pokepal101 02:42, 29 December 2012 (MSK)) |
The vector API provides methods to create and manipulate vectors. An introduction to vectors can be found on Wikipedia.
Method Name | Description |
vector.new(float x, float y, float z) | Creates a vector. |
vectorA:add(vector vectorB) | Adds vectorB to vectorA and returns the resulted vector. Can also be used by writing vectorA + vectorB. |
vectorA:sub(vector vectorB) | Subtracts vectorB from vectorA and returns the resulting vector. Can also be used by writing vectorA - vectorB. |
vectorA:mul(float n) | Scalar multiplies vectorA with n and returns the resulting vector. Can also be used by writing vectorA * n. |
vectorA:dot(vector vectorB) | Returns the dot product of vectorA and vectorB. |
vectorA:cross(vector 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". |