Difference between revisions of "Vector (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Changed to match other function pages)
(Someone really borked up the HTML table. Fixed.)
Line 5: Line 5:
 
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
 
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;">
 
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
 
<tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;">
&nbsp;&nbsp;
+
[[File:Grid_disk.png|24px]]&nbsp;&nbsp;
 
Vector (API)
 
Vector (API)
 
</td></tr>
 
</td></tr>
 +
 +
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
 +
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vector.new]](x, y, z)</td>
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vector.new]](x, y, z)</td>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Creates a vector.</td></tr>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Creates a vector.</td></tr>
Line 37: Line 40:
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:tostring]]()</td>
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[vectorA:tostring]]()</td>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a string representation of the vector in the form of "x,y,z".</td></tr>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a string representation of the vector in the form of "x,y,z".</td></tr>
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;"></td>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;"></td></tr>
 
 
</table>
 
</table>
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 17:11, 30 December 2012

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.

Grid disk.png   Vector (API)

Method NameDescription
vector.new(x, y, 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 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(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".