@@ -2,6 +2,106 @@ name: 'matrix'
2
2
description : |
3
3
Matrices are one of the most powerful features of MTA [OOP](/OOP). We did have a presence of Matrices before with [getElementMatrix](/getElementMatrix), but we were given an ugly disgusting table to play with. Now, with the new Matrix class, we can make and magically manipulate Matrices.
4
4
5
+ methods :
6
+ - name : create
7
+ description : |
8
+ Default constructor for the Matrix class. Returns a Matrix object.
9
+ Can be instantiated in multiple ways.
10
+ overloads :
11
+ - signature : Matrix(Vector3 position[, Vector3 rotation])
12
+ parameters :
13
+ - name : position
14
+ type : Vector3
15
+ description : The position vector of the matrix
16
+ - name : rotation
17
+ type : Vector3
18
+ optional : true
19
+ description : The rotation vector of the matrix
20
+ - signature : Matrix(Matrix matrixToClone)
21
+ parameters :
22
+ - name : matrixToClone
23
+ type : Matrix
24
+ description : A matrix you want to make a clone of
25
+ - signature : Matrix()
26
+ parameters : []
27
+ description : Initialize a zero matrix
28
+
29
+ - name : transformPosition
30
+ description : Transforms a given position vector using the Matrix.
31
+ signature : Vector3 Matrix:transformPosition(Vector3 position)
32
+ parameters :
33
+ - name : position
34
+ type : Vector3
35
+ description : The position vector you want to transform
36
+ examples :
37
+ - description : Teleports a random player 5 meters in front of them
38
+ code : |
39
+ local player = getRandomPlayer()
40
+ local desiredRelativePosition = Vector3(0, 5, 0)
41
+ local matrix = player.matrix
42
+ local newPosition = matrix:transformPosition(desiredRelativePosition)
43
+ player.position = newPosition
44
+
45
+ - name : getPosition
46
+ description : Returns the position vector of the matrix.
47
+ signature : Vector3 Matrix:getPosition()
48
+ parameters : []
49
+ examples :
50
+ - description : Prints the position of a random player.
51
+ code : |
52
+ local player = getRandomPlayer()
53
+ local matrix = player.matrix
54
+ local position = matrix:getPosition()
55
+ outputChatBox("x: " .. position:getX() .. ", y: " .. position:getY() .. ", z:" .. position:getZ())
56
+
57
+ - name : getRotation
58
+ description : Returns the rotation vector of the matrix.
59
+ signature : Vector3 Matrix:getRotation()
60
+ parameters : []
61
+ examples :
62
+ - description : Prints the rotation of a random player.
63
+ code : |
64
+ local player = getRandomPlayer()
65
+ local matrix = player.matrix
66
+ local rotation = matrix:getRotation()
67
+ outputChatBox("rx: " .. rotation:getX() .. ", ry: " .. rotation:getY() .. ", rz:" .. rotation:getZ())
68
+
69
+ - name : getForward
70
+ description : Returns the forward vector of the matrix.
71
+ signature : Vector3 Matrix:getForward()
72
+ parameters : []
73
+ examples :
74
+ - description : Prints the forward vector of a random player.
75
+ code : |
76
+ local player = getRandomPlayer()
77
+ local matrix = player.matrix
78
+ local vector = matrix:getForward()
79
+ outputChatBox("X: " .. vector:getX() .. ", Y: " .. vector:getY() .. ", Z:" .. vector:getZ())
80
+
81
+ - name : getRight
82
+ description : Returns the right vector of the matrix.
83
+ signature : Vector3 Matrix:getRight()
84
+ parameters : []
85
+ examples :
86
+ - description : Prints the right vector of a random player.
87
+ code : |
88
+ local player = getRandomPlayer()
89
+ local matrix = player.matrix
90
+ local vector = matrix:getRight()
91
+ outputChatBox("X: " .. vector:getX() .. ", Y: " .. vector:getY() .. ", Z:" .. vector:getZ())
92
+
93
+ - name : getUp
94
+ description : Returns the up vector of the matrix.
95
+ signature : Vector3 Matrix:getUp()
96
+ parameters : []
97
+ examples :
98
+ - description : Prints the up vector of a random player.
99
+ code : |
100
+ local player = getRandomPlayer()
101
+ local matrix = player.matrix
102
+ local vector = matrix:getUp()
103
+ outputChatBox("X: " .. vector:getX() .. ", Y: " .. vector:getY() .. ", Z:" .. vector:getZ())
104
+
5
105
examples :
6
106
- path : examples/matrix-1.lua
7
107
description : >
0 commit comments