Debian Codegraph @

doc/classes/Vector4i.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="Vector4i" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A 4D vector using integer coordinates.
5 </brief_description>
6 <description>
7 A 4-element structure that can be used to represent 4D grid coordinates or any other quadruplet of integers.
8 It uses integer coordinates and is therefore preferable to [Vector4] when exact precision is required. Note that the values are limited to 32 bits, and unlike [Vector4] this cannot be configured with an engine build option. Use [int] or [PackedInt64Array] if 64-bit values are needed.
9 [b]Note:[/b] In a boolean context, a Vector4i will evaluate to [code]false[/code] if it's equal to [code]Vector4i(0, 0, 0, 0)[/code]. Otherwise, a Vector4i will always evaluate to [code]true[/code].
10 </description>
11 <tutorials>
12 </tutorials>
13 <constructors>
14 <constructor name="Vector4i">
15 <return type="Vector4i" />
16 <description>
17 Constructs a default-initialized [Vector4i] with all components set to [code]0[/code].
18 </description>
19 </constructor>
20 <constructor name="Vector4i">
21 <return type="Vector4i" />
22 <param index="0" name="from" type="Vector4i" />
23 <description>
24 Constructs a [Vector4i] as a copy of the given [Vector4i].
25 </description>
26 </constructor>
27 <constructor name="Vector4i">
28 <return type="Vector4i" />
29 <param index="0" name="from" type="Vector4" />
30 <description>
31 Constructs a new [Vector4i] from the given [Vector4] by truncating components' fractional parts (rounding towards zero). For a different behavior consider passing the result of [method Vector4.ceil], [method Vector4.floor] or [method Vector4.round] to this constructor instead.
32 </description>
33 </constructor>
34 <constructor name="Vector4i">
35 <return type="Vector4i" />
36 <param index="0" name="x" type="int" />
37 <param index="1" name="y" type="int" />
38 <param index="2" name="z" type="int" />
39 <param index="3" name="w" type="int" />
40 <description>
41 Returns a [Vector4i] with the given components.
42 </description>
43 </constructor>
44 </constructors>
45 <methods>
46 <method name="abs" qualifiers="const">
47 <return type="Vector4i" />
48 <description>
49 Returns a new vector with all components in absolute values (i.e. positive).
50 </description>
51 </method>
52 <method name="clamp" qualifiers="const">
53 <return type="Vector4i" />
54 <param index="0" name="min" type="Vector4i" />
55 <param index="1" name="max" type="Vector4i" />
56 <description>
57 Returns a new vector with all components clamped between the components of [param min] and [param max], by running [method @GlobalScope.clamp] on each component.
58 </description>
59 </method>
60 <method name="clampi" qualifiers="const">
61 <return type="Vector4i" />
62 <param index="0" name="min" type="int" />
63 <param index="1" name="max" type="int" />
64 <description>
65 Returns a new vector with all components clamped between [param min] and [param max], by running [method @GlobalScope.clamp] on each component.
66 </description>
67 </method>
68 <method name="distance_squared_to" qualifiers="const">
69 <return type="int" />
70 <param index="0" name="to" type="Vector4i" />
71 <description>
72 Returns the squared distance between this vector and [param to].
73 This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula.
74 </description>
75 </method>
76 <method name="distance_to" qualifiers="const">
77 <return type="float" />
78 <param index="0" name="to" type="Vector4i" />
79 <description>
80 Returns the distance between this vector and [param to].
81 </description>
82 </method>
83 <method name="length" qualifiers="const" keywords="size">
84 <return type="float" />
85 <description>
86 Returns the length (magnitude) of this vector.
87 </description>
88 </method>
89 <method name="length_squared" qualifiers="const">
90 <return type="int" />
91 <description>
92 Returns the squared length (squared magnitude) of this vector.
93 This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula.
94 </description>
95 </method>
96 <method name="max" qualifiers="const">
97 <return type="Vector4i" />
98 <param index="0" name="with" type="Vector4i" />
99 <description>
100 Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4i(maxi(x, with.x), maxi(y, with.y), maxi(z, with.z), maxi(w, with.w))[/code].
101 </description>
102 </method>
103 <method name="max_axis_index" qualifiers="const">
104 <return type="int" />
105 <description>
106 Returns the axis of the vector's highest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X].
107 </description>
108 </method>
109 <method name="maxi" qualifiers="const">
110 <return type="Vector4i" />
111 <param index="0" name="with" type="int" />
112 <description>
113 Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4i(maxi(x, with), maxi(y, with), maxi(z, with), maxi(w, with))[/code].
114 </description>
115 </method>
116 <method name="min" qualifiers="const">
117 <return type="Vector4i" />
118 <param index="0" name="with" type="Vector4i" />
119 <description>
120 Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4i(mini(x, with.x), mini(y, with.y), mini(z, with.z), mini(w, with.w))[/code].
121 </description>
122 </method>
123 <method name="min_axis_index" qualifiers="const">
124 <return type="int" />
125 <description>
126 Returns the axis of the vector's lowest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_W].
127 </description>
128 </method>
129 <method name="mini" qualifiers="const">
130 <return type="Vector4i" />
131 <param index="0" name="with" type="int" />
132 <description>
133 Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4i(mini(x, with), mini(y, with), mini(z, with), mini(w, with))[/code].
134 </description>
135 </method>
136 <method name="sign" qualifiers="const">
137 <return type="Vector4i" />
138 <description>
139 Returns a new vector with each component set to [code]1[/code] if it's positive, [code]-1[/code] if it's negative, and [code]0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component.
140 </description>
141 </method>
142 <method name="snapped" qualifiers="const">
143 <return type="Vector4i" />
144 <param index="0" name="step" type="Vector4i" />
145 <description>
146 Returns a new vector with each component snapped to the closest multiple of the corresponding component in [param step].
147 </description>
148 </method>
149 <method name="snappedi" qualifiers="const">
150 <return type="Vector4i" />
151 <param index="0" name="step" type="int" />
152 <description>
153 Returns a new vector with each component snapped to the closest multiple of [param step].
154 </description>
155 </method>
156 </methods>
157 <members>
158 <member name="w" type="int" setter="" getter="" default="0">
159 The vector's W component. Also accessible by using the index position [code][3][/code].
160 </member>
161 <member name="x" type="int" setter="" getter="" default="0">
162 The vector's X component. Also accessible by using the index position [code][0][/code].
163 </member>
164 <member name="y" type="int" setter="" getter="" default="0">
165 The vector's Y component. Also accessible by using the index position [code][1][/code].
166 </member>
167 <member name="z" type="int" setter="" getter="" default="0">
168 The vector's Z component. Also accessible by using the index position [code][2][/code].
169 </member>
170 </members>
171 <constants>
172 <constant name="AXIS_X" value="0" enum="Axis">
173 Enumerated value for the X axis. Returned by [method max_axis_index] and [method min_axis_index].
174 </constant>
175 <constant name="AXIS_Y" value="1" enum="Axis">
176 Enumerated value for the Y axis. Returned by [method max_axis_index] and [method min_axis_index].
177 </constant>
178 <constant name="AXIS_Z" value="2" enum="Axis">
179 Enumerated value for the Z axis. Returned by [method max_axis_index] and [method min_axis_index].
180 </constant>
181 <constant name="AXIS_W" value="3" enum="Axis">
182 Enumerated value for the W axis. Returned by [method max_axis_index] and [method min_axis_index].
183 </constant>
184 <constant name="ZERO" value="Vector4i(0, 0, 0, 0)">
185 Zero vector, a vector with all components set to [code]0[/code].
186 </constant>
187 <constant name="ONE" value="Vector4i(1, 1, 1, 1)">
188 One vector, a vector with all components set to [code]1[/code].
189 </constant>
190 <constant name="MIN" value="Vector4i(-2147483648, -2147483648, -2147483648, -2147483648)">
191 Min vector, a vector with all components equal to [code]INT32_MIN[/code]. Can be used as a negative integer equivalent of [constant Vector4.INF].
192 </constant>
193 <constant name="MAX" value="Vector4i(2147483647, 2147483647, 2147483647, 2147483647)">
194 Max vector, a vector with all components equal to [code]INT32_MAX[/code]. Can be used as an integer equivalent of [constant Vector4.INF].
195 </constant>
196 </constants>
197 <operators>
198 <operator name="operator !=">
199 <return type="bool" />
200 <param index="0" name="right" type="Vector4i" />
201 <description>
202 Returns [code]true[/code] if the vectors are not equal.
203 </description>
204 </operator>
205 <operator name="operator %">
206 <return type="Vector4i" />
207 <param index="0" name="right" type="Vector4i" />
208 <description>
209 Gets the remainder of each component of the [Vector4i] with the components of the given [Vector4i]. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using [method @GlobalScope.posmod] instead if you want to handle negative numbers.
210 [codeblock]
211 print(Vector4i(10, -20, 30, -40) % Vector4i(7, 8, 9, 10)) # Prints (3, -4, 3, 0)
212 [/codeblock]
213 </description>
214 </operator>
215 <operator name="operator %">
216 <return type="Vector4i" />
217 <param index="0" name="right" type="int" />
218 <description>
219 Gets the remainder of each component of the [Vector4i] with the given [int]. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using [method @GlobalScope.posmod] instead if you want to handle negative numbers.
220 [codeblock]
221 print(Vector4i(10, -20, 30, -40) % 7) # Prints (3, -6, 2, -5)
222 [/codeblock]
223 </description>
224 </operator>
225 <operator name="operator *">
226 <return type="Vector4i" />
227 <param index="0" name="right" type="Vector4i" />
228 <description>
229 Multiplies each component of the [Vector4i] by the components of the given [Vector4i].
230 [codeblock]
231 print(Vector4i(10, 20, 30, 40) * Vector4i(3, 4, 5, 6)) # Prints (30, 80, 150, 240)
232 [/codeblock]
233 </description>
234 </operator>
235 <operator name="operator *">
236 <return type="Vector4" />
237 <param index="0" name="right" type="float" />
238 <description>
239 Multiplies each component of the [Vector4i] by the given [float].
240 Returns a Vector4 value due to floating-point operations.
241 [codeblock]
242 print(Vector4i(10, 20, 30, 40) * 2) # Prints (20.0, 40.0, 60.0, 80.0)
243 [/codeblock]
244 </description>
245 </operator>
246 <operator name="operator *">
247 <return type="Vector4i" />
248 <param index="0" name="right" type="int" />
249 <description>
250 Multiplies each component of the [Vector4i] by the given [int].
251 </description>
252 </operator>
253 <operator name="operator +">
254 <return type="Vector4i" />
255 <param index="0" name="right" type="Vector4i" />
256 <description>
257 Adds each component of the [Vector4i] by the components of the given [Vector4i].
258 [codeblock]
259 print(Vector4i(10, 20, 30, 40) + Vector4i(3, 4, 5, 6)) # Prints (13, 24, 35, 46)
260 [/codeblock]
261 </description>
262 </operator>
263 <operator name="operator -">
264 <return type="Vector4i" />
265 <param index="0" name="right" type="Vector4i" />
266 <description>
267 Subtracts each component of the [Vector4i] by the components of the given [Vector4i].
268 [codeblock]
269 print(Vector4i(10, 20, 30, 40) - Vector4i(3, 4, 5, 6)) # Prints (7, 16, 25, 34)
270 [/codeblock]
271 </description>
272 </operator>
273 <operator name="operator /">
274 <return type="Vector4i" />
275 <param index="0" name="right" type="Vector4i" />
276 <description>
277 Divides each component of the [Vector4i] by the components of the given [Vector4i].
278 [codeblock]
279 print(Vector4i(10, 20, 30, 40) / Vector4i(2, 5, 3, 4)) # Prints (5, 4, 10, 10)
280 [/codeblock]
281 </description>
282 </operator>
283 <operator name="operator /">
284 <return type="Vector4" />
285 <param index="0" name="right" type="float" />
286 <description>
287 Divides each component of the [Vector4i] by the given [float].
288 Returns a Vector4 value due to floating-point operations.
289 [codeblock]
290 print(Vector4i(1, 2, 3, 4) / 2.5) # Prints (0.4, 0.8, 1.2, 1.6)
291 [/codeblock]
292 </description>
293 </operator>
294 <operator name="operator /">
295 <return type="Vector4i" />
296 <param index="0" name="right" type="int" />
297 <description>
298 Divides each component of the [Vector4i] by the given [int].
299 </description>
300 </operator>
301 <operator name="operator &lt;">
302 <return type="bool" />
303 <param index="0" name="right" type="Vector4i" />
304 <description>
305 Compares two [Vector4i] vectors by first checking if the X value of the left vector is less than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
306 </description>
307 </operator>
308 <operator name="operator &lt;=">
309 <return type="bool" />
310 <param index="0" name="right" type="Vector4i" />
311 <description>
312 Compares two [Vector4i] vectors by first checking if the X value of the left vector is less than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
313 </description>
314 </operator>
315 <operator name="operator ==">
316 <return type="bool" />
317 <param index="0" name="right" type="Vector4i" />
318 <description>
319 Returns [code]true[/code] if the vectors are exactly equal.
320 </description>
321 </operator>
322 <operator name="operator &gt;">
323 <return type="bool" />
324 <param index="0" name="right" type="Vector4i" />
325 <description>
326 Compares two [Vector4i] vectors by first checking if the X value of the left vector is greater than the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
327 </description>
328 </operator>
329 <operator name="operator &gt;=">
330 <return type="bool" />
331 <param index="0" name="right" type="Vector4i" />
332 <description>
333 Compares two [Vector4i] vectors by first checking if the X value of the left vector is greater than or equal to the X value of the [param right] vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors, Z values of the two vectors, and then with the W values. This operator is useful for sorting vectors.
334 </description>
335 </operator>
336 <operator name="operator []">
337 <return type="int" />
338 <param index="0" name="index" type="int" />
339 <description>
340 Access vector components using their [param index]. [code]v[0][/code] is equivalent to [code]v.x[/code], [code]v[1][/code] is equivalent to [code]v.y[/code], [code]v[2][/code] is equivalent to [code]v.z[/code], and [code]v[3][/code] is equivalent to [code]v.w[/code].
341 </description>
342 </operator>
343 <operator name="operator unary+">
344 <return type="Vector4i" />
345 <description>
346 Returns the same value as if the [code]+[/code] was not there. Unary [code]+[/code] does nothing, but sometimes it can make your code more readable.
347 </description>
348 </operator>
349 <operator name="operator unary-">
350 <return type="Vector4i" />
351 <description>
352 Returns the negative value of the [Vector4i]. This is the same as writing [code]Vector4i(-v.x, -v.y, -v.z, -v.w)[/code]. This operation flips the direction of the vector while keeping the same magnitude.
353 </description>
354 </operator>
355 </operators>
356 </class>