Vector API
|
|||||||||||
Given two vectors, self and object, this function will add the object to self to create a new vector. This can also be written as self + object . If either argument was not created with vector.new, this function will not work as designed. |
|||||||||||
Syntax | vector.add(
Colon notation: self:add(
|
||||||||||
Returns | table vector | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
|
|
|||||||||||
Given two vectors, self and object, this function will output their cross product. If the arguments do not follow Computercraft's vector style (a table with the contents: x, y, and z) the function could output undesired results. | |||||||||||
Syntax | vector.cross(
Colon notation: self:cross(
|
||||||||||
Returns | table cross product | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
| |||||||||||
|
|
|||||||||||
Given a vector, self, and a scalar this function will divide each component in self by the scalar to create a new vector. This can also be written as self / scalar . If self was not created with vector.new, this function will not work as designed. |
|||||||||||
Syntax | vector.div(
Colon notation: self:div(
|
||||||||||
Returns | table vector | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
|
|
|||||||||||
Given two vectors, self and object, this function will multiply and add the components of object and self and output their dot product. If either argument does not follow Computercraft's vector style (a table with the contents: x, y, and z) the function will error. | |||||||||||
Syntax | vector.dot(
Colon notation: self:dot(
|
||||||||||
Returns | number dot product | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
| |||||||||||
|
|
|||||||||||
Given a vector, self, this function will square and add the components of self to define the length of the vector. If self does not follow Computercraft's vector style (a table with the contents: x, y, and z) the function will error. | |||||||||||
Syntax | vector.length(
Colon notation: self:length() |
||||||||||
Returns | number length | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
| |||||||||||
|
|
|||||||||||
Given a vector, self, and a scalar this function will multiply each component in self by the scalar to create a new vector. This can also be written as self * scalar . If self was not created with vector.new, this function will not work as designed. |
|||||||||||
Syntax | vector.mul(
Colon notation: self:mul(
|
||||||||||
Returns | table vector | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
|
|
|||||||||||
Given three coordinates, x, y, and z, this function will create a new vector when called. If an argument is not a number and cannot be converted to a number the corresponding coordinate will default to zero. | |||||||||||
Syntax | vector.new(
|
||||||||||
Returns | table vector | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
| |||||||||||
|
|
|||||||||||
Given a vector, self, this function will convert self to a unit vector, utilizing a process known as normalization. If self does not follow Computercraft's vector style (a table with the contents: x, y, and z) the function may return unexpected results. | |||||||||||
Syntax | vector.normalize(
Colon notation: self:normalize() |
||||||||||
Returns | table vector | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
| |||||||||||
|
Vector.round
|
|||||||||||
Given two vectors, self and object, this function will subtract object from self to create a new vector. This can also be written as self - object . If either argument was not created with vector.new, this function will not work as designed. |
|||||||||||
Syntax | vector.sub(
Colon notation: self:sub(
|
||||||||||
Returns | table vector | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
|
|
|||||||||||
Given a vector, self, this function will create a new string out of the vector's components. This can also be written as print(self) . If self does not follow Computercraft's vector style (a table with the contents: x, y, and z) the function will error. |
|||||||||||
Syntax | vector.tostring(
Colon notation: self:tostring() |
||||||||||
Returns | string vector | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
|
|
|||||||||||
Given a vector, self, this function will apply the unary operation, unary minus, to each component in self to create a new vector. This can also be written as -self . If self was not created with vector.new, this function will not work as designed. |
|||||||||||
Syntax | vector.unm(
Colon notation: self:unm() |
||||||||||
Returns | table vector | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | vector | ||||||||||
|
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.