Category:Vector

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Only Vector "creates" vectors)
(Added indexing examples)
 
Line 4: Line 4:
 
{{ClassFields
 
{{ClassFields
 
|Fields=
 
|Fields=
{{ClassField|number|x|The X component of the vector.}}
+
{{ClassField|number|'''x''' or '''1'''|The X component of the vector.}}
{{ClassField|number|y|The Y component of the vector.}}
+
{{ClassField|number|'''y''' or '''2'''|The Y component of the vector.}}
{{ClassField|number|z|The Z component of the vector.}}
+
{{ClassField|number|'''z''' or '''3'''|The Z component of the vector.}}
 +
}}
 +
{{Example
 +
|Description=Indexing by named component.
 +
|Code=local v = Vector( 1, 2, 3 )
 +
print( v.x, v.y, v.z )
 +
|Output=1 2 3
 +
}}
 +
{{Example
 +
|Description=Indexing by number (most efficient!).
 +
|Code=local v = Vector( 1, 2, 3 )
 +
print( v[1], v[2], v[3] )
 +
|Output=1 2 3
 
}}
 
}}

Latest revision as of 10:19, 24 October 2019

List of all possible functions to manipulate vectors.

Created by Vector.

Contents

Fields

Type Name Description
number x or 1 The X component of the vector.
number y or 2 The Y component of the vector.
number z or 3 The Z component of the vector.

Examples

Example

Indexing by named component.

local v = Vector( 1, 2, 3 )
print( v.x, v.y, v.z )

Output:

1 2 3

Examples

Example

Indexing by number (most efficient!).

local v = Vector( 1, 2, 3 )
print( v[1], v[2], v[3] )

Output:

1 2 3
Personal tools
Navigation