You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ported Luau documentation for vector library to the Roblox documentation (#957)
## Changes
The Luau team has recently developed and added to the [Luau
documentation a new `vector`
library](https://luau.org/library#vector-library), although this change
has not been reflected into the Roblox Creator Documentation. To avoid
potential confusion for developers who encounter a new undocumented
library, I've decided to port the Luau `vector` documentation, with
minimal changes (only omitting features not available in the Roblox
environment such as 4-wide mode) to keep it concise and accurate to the
Roblox environment.
## Checks
By submitting your pull request for review, you agree to the following:
- [x] This contribution was created in whole or in part by me, and I
have the right to submit it under the terms of this repository's open
source licenses.
- [x] I understand and agree that this contribution and a record of it
are public, maintained indefinitely, and may be redistributed under the
terms of this repository's open source licenses.
- [x] To the best of my knowledge, all proposed changes are accurate.
---------
This library implements functionality for the vector type in addition to the built-in primitive operator support. It uses vectors with three components (`x`, `y`, and `z`).
7
+
8
+
Individual vector components can be accessed using the fields `x` or `X`, `y` or `Y`, `z` or `Z`. Since vector values are immutable, writing to individual components is not supported.
9
+
code_samples:
10
+
properties:
11
+
- name: vector.zero
12
+
type: vector
13
+
summary: Constant vector with all components set to `0`.
14
+
description: Constant vector with all components set to `0`.
15
+
tags:
16
+
code_samples:
17
+
- name: vector.one
18
+
type: vector
19
+
summary: Constant vector with all components set to `1`.
20
+
description: Constant vector with all components set to `1`.
21
+
tags:
22
+
code_samples:
23
+
functions:
24
+
- name: vector.create
25
+
summary: Creates a new vector with the given component values.
26
+
description: Creates a new vector with the given component values.
27
+
parameters:
28
+
- name: x
29
+
type: number
30
+
default:
31
+
summary: ''
32
+
- name: y
33
+
type: number
34
+
default:
35
+
summary: ''
36
+
- name: z
37
+
type: number
38
+
default:
39
+
summary: ''
40
+
returns:
41
+
- type: vector
42
+
summary: ''
43
+
tags:
44
+
code_samples:
45
+
- name: vector.magnitude
46
+
summary: Calculates the magnitude of a given vector.
47
+
description: Calculates the magnitude of a given vector.
48
+
parameters:
49
+
- name: vec
50
+
type: vector
51
+
default:
52
+
summary: ''
53
+
returns:
54
+
- type: number
55
+
summary: ''
56
+
tags:
57
+
code_samples:
58
+
- name: vector.normalize
59
+
summary: Computes the normalized version (unit vector) of a given vector.
60
+
description: Computes the normalized version (unit vector) of a given vector.
61
+
parameters:
62
+
- name: vec
63
+
type: vector
64
+
default:
65
+
summary: ''
66
+
returns:
67
+
- type: vector
68
+
summary: ''
69
+
tags:
70
+
code_samples:
71
+
- name: vector.cross
72
+
summary: Computes the cross product of two vectors.
73
+
description: Computes the cross product of two vectors.
74
+
parameters:
75
+
- name: vec1
76
+
type: vector
77
+
default:
78
+
summary: ''
79
+
- name: vec2
80
+
type: vector
81
+
default:
82
+
summary: ''
83
+
returns:
84
+
- type: vector
85
+
summary: ''
86
+
tags:
87
+
code_samples:
88
+
- name: vector.dot
89
+
summary: Computes the dot product of two vectors.
90
+
description: Computes the dot product of two vectors.
91
+
parameters:
92
+
- name: vec1
93
+
type: vector
94
+
default:
95
+
summary: ''
96
+
- name: vec2
97
+
type: vector
98
+
default:
99
+
summary: ''
100
+
returns:
101
+
- type: number
102
+
summary: ''
103
+
tags:
104
+
code_samples:
105
+
- name: vector.angle
106
+
summary: Computes the angle between two vectors in radians.
107
+
description: |
108
+
Computes the angle between two vectors in radians. The axis, if specified, is used to determine the sign of the angle.
109
+
parameters:
110
+
- name: vec1
111
+
type: vector
112
+
default:
113
+
summary: ''
114
+
- name: vec2
115
+
type: vector
116
+
default:
117
+
summary: ''
118
+
- name: axis
119
+
type: vector?
120
+
default:
121
+
summary: ''
122
+
returns:
123
+
- type: number
124
+
summary: ''
125
+
tags:
126
+
code_samples:
127
+
- name: vector.floor
128
+
summary: Applies `Library.math.floor()` to every component of the input vector.
129
+
description: Applies `Library.math.floor()` to every component of the input vector.
130
+
parameters:
131
+
- name: vec
132
+
type: vector
133
+
default:
134
+
summary: ''
135
+
returns:
136
+
- type: vector
137
+
summary: ''
138
+
tags:
139
+
code_samples:
140
+
- name: vector.ceil
141
+
summary: Applies `Library.math.ceil()` to every component of the input vector.
142
+
description: Applies `Library.math.ceil()` to every component of the input vector.
143
+
parameters:
144
+
- name: vec
145
+
type: vector
146
+
default:
147
+
summary: ''
148
+
returns:
149
+
- type: vector
150
+
summary: ''
151
+
tags:
152
+
code_samples:
153
+
- name: vector.abs
154
+
summary: Applies `Library.math.abs()` to every component of the input vector.
155
+
description: Applies `Library.math.abs()` to every component of the input vector.
156
+
parameters:
157
+
- name: vec
158
+
type: vector
159
+
default:
160
+
summary: ''
161
+
returns:
162
+
- type: vector
163
+
summary: ''
164
+
tags:
165
+
code_samples:
166
+
- name: vector.sign
167
+
summary: Applies `Library.math.sign()` to every component of the input vector.
168
+
description: Applies `Library.math.sign()` to every component of the input vector.
169
+
parameters:
170
+
- name: vec
171
+
type: vector
172
+
default:
173
+
summary: ''
174
+
returns:
175
+
- type: vector
176
+
summary: ''
177
+
tags:
178
+
code_samples:
179
+
- name: vector.clamp
180
+
summary: Applies `Library.math.clamp()` to every component of the input vector.
181
+
description: Applies `Library.math.clamp()` to every component of the input vector.
182
+
parameters:
183
+
- name: vec
184
+
type: vector
185
+
default:
186
+
summary: ''
187
+
- name: min
188
+
type: vector
189
+
default:
190
+
summary: ''
191
+
- name: max
192
+
type: vector
193
+
default:
194
+
summary: ''
195
+
returns:
196
+
- type: vector
197
+
summary: ''
198
+
tags:
199
+
code_samples:
200
+
- name: vector.max
201
+
summary: Applies `Library.math.max()` to the corresponding components of the input vectors.
202
+
description: |
203
+
Applies `Library.math.max()` to the corresponding components of the input vectors.
204
+
parameters:
205
+
- name: ...
206
+
type: vector
207
+
default:
208
+
summary: ''
209
+
returns:
210
+
- type: vector
211
+
summary: ''
212
+
tags:
213
+
code_samples:
214
+
- name: vector.min
215
+
summary: Applies `Library.math.min()` to the corresponding components of the input vectors.
216
+
description: |
217
+
Applies `Library.math.min()` to the corresponding components of the input vectors.
0 commit comments