Debian Codegraph @

doc/classes/Vector3i.xml

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