| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="Vector4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | A 4D vector using floating-point coordinates. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | A 4-element structure that can be used to represent 4D coordinates or any other quadruplet of numeric values. |
| 8 | It uses floating-point coordinates. By default, these floating-point values use 32-bit precision, unlike [float] which is always 64-bit. If double precision is needed, compile the engine with the option [code]precision=double[/code]. |
| 9 | See [Vector4i] for its integer counterpart. |
| 10 | [b]Note:[/b] In a boolean context, a Vector4 will evaluate to [code]false[/code] if it's equal to [code]Vector4(0, 0, 0, 0)[/code]. Otherwise, a Vector4 will always evaluate to [code]true[/code]. |
| 11 | </description> |
| 12 | <tutorials> |
| 13 | </tutorials> |
| 14 | <constructors> |
| 15 | <constructor name="Vector4"> |
| 16 | <return type="Vector4" /> |
| 17 | <description> |
| 18 | Constructs a default-initialized [Vector4] with all components set to [code]0[/code]. |
| 19 | </description> |
| 20 | </constructor> |
| 21 | <constructor name="Vector4"> |
| 22 | <return type="Vector4" /> |
| 23 | <param index="0" name="from" type="Vector4" /> |
| 24 | <description> |
| 25 | Constructs a [Vector4] as a copy of the given [Vector4]. |
| 26 | </description> |
| 27 | </constructor> |
| 28 | <constructor name="Vector4"> |
| 29 | <return type="Vector4" /> |
| 30 | <param index="0" name="from" type="Vector4i" /> |
| 31 | <description> |
| 32 | Constructs a new [Vector4] from the given [Vector4i]. |
| 33 | </description> |
| 34 | </constructor> |
| 35 | <constructor name="Vector4"> |
| 36 | <return type="Vector4" /> |
| 37 | <param index="0" name="x" type="float" /> |
| 38 | <param index="1" name="y" type="float" /> |
| 39 | <param index="2" name="z" type="float" /> |
| 40 | <param index="3" name="w" type="float" /> |
| 41 | <description> |
| 42 | Returns a [Vector4] with the given components. |
| 43 | </description> |
| 44 | </constructor> |
| 45 | </constructors> |
| 46 | <methods> |
| 47 | <method name="abs" qualifiers="const"> |
| 48 | <return type="Vector4" /> |
| 49 | <description> |
| 50 | Returns a new vector with all components in absolute values (i.e. positive). |
| 51 | </description> |
| 52 | </method> |
| 53 | <method name="ceil" qualifiers="const"> |
| 54 | <return type="Vector4" /> |
| 55 | <description> |
| 56 | Returns a new vector with all components rounded up (towards positive infinity). |
| 57 | </description> |
| 58 | </method> |
| 59 | <method name="clamp" qualifiers="const"> |
| 60 | <return type="Vector4" /> |
| 61 | <param index="0" name="min" type="Vector4" /> |
| 62 | <param index="1" name="max" type="Vector4" /> |
| 63 | <description> |
| 64 | 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. |
| 65 | </description> |
| 66 | </method> |
| 67 | <method name="clampf" qualifiers="const"> |
| 68 | <return type="Vector4" /> |
| 69 | <param index="0" name="min" type="float" /> |
| 70 | <param index="1" name="max" type="float" /> |
| 71 | <description> |
| 72 | Returns a new vector with all components clamped between [param min] and [param max], by running [method @GlobalScope.clamp] on each component. |
| 73 | </description> |
| 74 | </method> |
| 75 | <method name="cubic_interpolate" qualifiers="const"> |
| 76 | <return type="Vector4" /> |
| 77 | <param index="0" name="b" type="Vector4" /> |
| 78 | <param index="1" name="pre_a" type="Vector4" /> |
| 79 | <param index="2" name="post_b" type="Vector4" /> |
| 80 | <param index="3" name="weight" type="float" /> |
| 81 | <description> |
| 82 | Performs a cubic interpolation between this vector and [param b] using [param pre_a] and [param post_b] as handles, and returns the result at position [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. |
| 83 | </description> |
| 84 | </method> |
| 85 | <method name="cubic_interpolate_in_time" qualifiers="const"> |
| 86 | <return type="Vector4" /> |
| 87 | <param index="0" name="b" type="Vector4" /> |
| 88 | <param index="1" name="pre_a" type="Vector4" /> |
| 89 | <param index="2" name="post_b" type="Vector4" /> |
| 90 | <param index="3" name="weight" type="float" /> |
| 91 | <param index="4" name="b_t" type="float" /> |
| 92 | <param index="5" name="pre_a_t" type="float" /> |
| 93 | <param index="6" name="post_b_t" type="float" /> |
| 94 | <description> |
| 95 | Performs a cubic interpolation between this vector and [param b] using [param pre_a] and [param post_b] as handles, and returns the result at position [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation. |
| 96 | It can perform smoother interpolation than [method cubic_interpolate] by the time values. |
| 97 | </description> |
| 98 | </method> |
| 99 | <method name="direction_to" qualifiers="const"> |
| 100 | <return type="Vector4" /> |
| 101 | <param index="0" name="to" type="Vector4" /> |
| 102 | <description> |
| 103 | Returns the normalized vector pointing from this vector to [param to]. This is equivalent to using [code](b - a).normalized()[/code]. |
| 104 | </description> |
| 105 | </method> |
| 106 | <method name="distance_squared_to" qualifiers="const"> |
| 107 | <return type="float" /> |
| 108 | <param index="0" name="to" type="Vector4" /> |
| 109 | <description> |
| 110 | Returns the squared distance between this vector and [param to]. |
| 111 | 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. |
| 112 | </description> |
| 113 | </method> |
| 114 | <method name="distance_to" qualifiers="const"> |
| 115 | <return type="float" /> |
| 116 | <param index="0" name="to" type="Vector4" /> |
| 117 | <description> |
| 118 | Returns the distance between this vector and [param to]. |
| 119 | </description> |
| 120 | </method> |
| 121 | <method name="dot" qualifiers="const"> |
| 122 | <return type="float" /> |
| 123 | <param index="0" name="with" type="Vector4" /> |
| 124 | <description> |
| 125 | Returns the dot product of this vector and [param with]. |
| 126 | </description> |
| 127 | </method> |
| 128 | <method name="floor" qualifiers="const"> |
| 129 | <return type="Vector4" /> |
| 130 | <description> |
| 131 | Returns a new vector with all components rounded down (towards negative infinity). |
| 132 | </description> |
| 133 | </method> |
| 134 | <method name="inverse" qualifiers="const"> |
| 135 | <return type="Vector4" /> |
| 136 | <description> |
| 137 | Returns the inverse of the vector. This is the same as [code]Vector4(1.0 / v.x, 1.0 / v.y, 1.0 / v.z, 1.0 / v.w)[/code]. |
| 138 | </description> |
| 139 | </method> |
| 140 | <method name="is_equal_approx" qualifiers="const"> |
| 141 | <return type="bool" /> |
| 142 | <param index="0" name="to" type="Vector4" /> |
| 143 | <description> |
| 144 | Returns [code]true[/code] if this vector and [param to] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. |
| 145 | </description> |
| 146 | </method> |
| 147 | <method name="is_finite" qualifiers="const"> |
| 148 | <return type="bool" /> |
| 149 | <description> |
| 150 | Returns [code]true[/code] if this vector is finite, by calling [method @GlobalScope.is_finite] on each component. |
| 151 | </description> |
| 152 | </method> |
| 153 | <method name="is_normalized" qualifiers="const"> |
| 154 | <return type="bool" /> |
| 155 | <description> |
| 156 | Returns [code]true[/code] if the vector is normalized, i.e. its length is approximately equal to 1. |
| 157 | </description> |
| 158 | </method> |
| 159 | <method name="is_zero_approx" qualifiers="const"> |
| 160 | <return type="bool" /> |
| 161 | <description> |
| 162 | Returns [code]true[/code] if this vector's values are approximately zero, by running [method @GlobalScope.is_zero_approx] on each component. |
| 163 | This method is faster than using [method is_equal_approx] with one value as a zero vector. |
| 164 | </description> |
| 165 | </method> |
| 166 | <method name="length" qualifiers="const" keywords="size"> |
| 167 | <return type="float" /> |
| 168 | <description> |
| 169 | Returns the length (magnitude) of this vector. |
| 170 | </description> |
| 171 | </method> |
| 172 | <method name="length_squared" qualifiers="const"> |
| 173 | <return type="float" /> |
| 174 | <description> |
| 175 | Returns the squared length (squared magnitude) of this vector. |
| 176 | This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula. |
| 177 | </description> |
| 178 | </method> |
| 179 | <method name="lerp" qualifiers="const" keywords="interpolate"> |
| 180 | <return type="Vector4" /> |
| 181 | <param index="0" name="to" type="Vector4" /> |
| 182 | <param index="1" name="weight" type="float" /> |
| 183 | <description> |
| 184 | Returns the result of the linear interpolation between this vector and [param to] by amount [param weight]. [param weight] is on the range of [code]0.0[/code] to [code]1.0[/code], representing the amount of interpolation. |
| 185 | </description> |
| 186 | </method> |
| 187 | <method name="max" qualifiers="const"> |
| 188 | <return type="Vector4" /> |
| 189 | <param index="0" name="with" type="Vector4" /> |
| 190 | <description> |
| 191 | Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4(maxf(x, with.x), maxf(y, with.y), maxf(z, with.z), maxf(w, with.w))[/code]. |
| 192 | </description> |
| 193 | </method> |
| 194 | <method name="max_axis_index" qualifiers="const"> |
| 195 | <return type="int" /> |
| 196 | <description> |
| 197 | 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]. |
| 198 | </description> |
| 199 | </method> |
| 200 | <method name="maxf" qualifiers="const"> |
| 201 | <return type="Vector4" /> |
| 202 | <param index="0" name="with" type="float" /> |
| 203 | <description> |
| 204 | Returns the component-wise maximum of this and [param with], equivalent to [code]Vector4(maxf(x, with), maxf(y, with), maxf(z, with), maxf(w, with))[/code]. |
| 205 | </description> |
| 206 | </method> |
| 207 | <method name="min" qualifiers="const"> |
| 208 | <return type="Vector4" /> |
| 209 | <param index="0" name="with" type="Vector4" /> |
| 210 | <description> |
| 211 | Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4(minf(x, with.x), minf(y, with.y), minf(z, with.z), minf(w, with.w))[/code]. |
| 212 | </description> |
| 213 | </method> |
| 214 | <method name="min_axis_index" qualifiers="const"> |
| 215 | <return type="int" /> |
| 216 | <description> |
| 217 | 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]. |
| 218 | </description> |
| 219 | </method> |
| 220 | <method name="minf" qualifiers="const"> |
| 221 | <return type="Vector4" /> |
| 222 | <param index="0" name="with" type="float" /> |
| 223 | <description> |
| 224 | Returns the component-wise minimum of this and [param with], equivalent to [code]Vector4(minf(x, with), minf(y, with), minf(z, with), minf(w, with))[/code]. |
| 225 | </description> |
| 226 | </method> |
| 227 | <method name="normalized" qualifiers="const"> |
| 228 | <return type="Vector4" /> |
| 229 | <description> |
| 230 | Returns the result of scaling the vector to unit length. Equivalent to [code]v / v.length()[/code]. Returns [code](0, 0, 0, 0)[/code] if [code]v.length() == 0[/code]. See also [method is_normalized]. |
| 231 | [b]Note:[/b] This function may return incorrect values if the input vector length is near zero. |
| 232 | </description> |
| 233 | </method> |
| 234 | <method name="posmod" qualifiers="const"> |
| 235 | <return type="Vector4" /> |
| 236 | <param index="0" name="mod" type="float" /> |
| 237 | <description> |
| 238 | Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param mod]. |
| 239 | </description> |
| 240 | </method> |
| 241 | <method name="posmodv" qualifiers="const"> |
| 242 | <return type="Vector4" /> |
| 243 | <param index="0" name="modv" type="Vector4" /> |
| 244 | <description> |
| 245 | Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param modv]'s components. |
| 246 | </description> |
| 247 | </method> |
| 248 | <method name="round" qualifiers="const"> |
| 249 | <return type="Vector4" /> |
| 250 | <description> |
| 251 | Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero. |
| 252 | </description> |
| 253 | </method> |
| 254 | <method name="sign" qualifiers="const"> |
| 255 | <return type="Vector4" /> |
| 256 | <description> |
| 257 | Returns a new vector with each component set to [code]1.0[/code] if it's positive, [code]-1.0[/code] if it's negative, and [code]0.0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component. |
| 258 | </description> |
| 259 | </method> |
| 260 | <method name="snapped" qualifiers="const"> |
| 261 | <return type="Vector4" /> |
| 262 | <param index="0" name="step" type="Vector4" /> |
| 263 | <description> |
| 264 | Returns a new vector with each component snapped to the nearest multiple of the corresponding component in [param step]. This can also be used to round the components to an arbitrary number of decimals. |
| 265 | </description> |
| 266 | </method> |
| 267 | <method name="snappedf" qualifiers="const"> |
| 268 | <return type="Vector4" /> |
| 269 | <param index="0" name="step" type="float" /> |
| 270 | <description> |
| 271 | Returns a new vector with each component snapped to the nearest multiple of [param step]. This can also be used to round the components to an arbitrary number of decimals. |
| 272 | </description> |
| 273 | </method> |
| 274 | </methods> |
| 275 | <members> |
| 276 | <member name="w" type="float" setter="" getter="" default="0.0"> |
| 277 | The vector's W component. Also accessible by using the index position [code][3][/code]. |
| 278 | </member> |
| 279 | <member name="x" type="float" setter="" getter="" default="0.0"> |
| 280 | The vector's X component. Also accessible by using the index position [code][0][/code]. |
| 281 | </member> |
| 282 | <member name="y" type="float" setter="" getter="" default="0.0"> |
| 283 | The vector's Y component. Also accessible by using the index position [code][1][/code]. |
| 284 | </member> |
| 285 | <member name="z" type="float" setter="" getter="" default="0.0"> |
| 286 | The vector's Z component. Also accessible by using the index position [code][2][/code]. |
| 287 | </member> |
| 288 | </members> |
| 289 | <constants> |
| 290 | <constant name="AXIS_X" value="0" enum="Axis"> |
| 291 | Enumerated value for the X axis. Returned by [method max_axis_index] and [method min_axis_index]. |
| 292 | </constant> |
| 293 | <constant name="AXIS_Y" value="1" enum="Axis"> |
| 294 | Enumerated value for the Y axis. Returned by [method max_axis_index] and [method min_axis_index]. |
| 295 | </constant> |
| 296 | <constant name="AXIS_Z" value="2" enum="Axis"> |
| 297 | Enumerated value for the Z axis. Returned by [method max_axis_index] and [method min_axis_index]. |
| 298 | </constant> |
| 299 | <constant name="AXIS_W" value="3" enum="Axis"> |
| 300 | Enumerated value for the W axis. Returned by [method max_axis_index] and [method min_axis_index]. |
| 301 | </constant> |
| 302 | <constant name="ZERO" value="Vector4(0, 0, 0, 0)"> |
| 303 | Zero vector, a vector with all components set to [code]0[/code]. |
| 304 | </constant> |
| 305 | <constant name="ONE" value="Vector4(1, 1, 1, 1)"> |
| 306 | One vector, a vector with all components set to [code]1[/code]. |
| 307 | </constant> |
| 308 | <constant name="INF" value="Vector4(inf, inf, inf, inf)"> |
| 309 | Infinity vector, a vector with all components set to [constant @GDScript.INF]. |
| 310 | </constant> |
| 311 | </constants> |
| 312 | <operators> |
| 313 | <operator name="operator !="> |
| 314 | <return type="bool" /> |
| 315 | <param index="0" name="right" type="Vector4" /> |
| 316 | <description> |
| 317 | Returns [code]true[/code] if the vectors are not equal. |
| 318 | [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable. |
| 319 | [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included. |
| 320 | </description> |
| 321 | </operator> |
| 322 | <operator name="operator *"> |
| 323 | <return type="Vector4" /> |
| 324 | <param index="0" name="right" type="Projection" /> |
| 325 | <description> |
| 326 | Transforms (multiplies) the [Vector4] by the transpose of the given [Projection] matrix. |
| 327 | For transforming by inverse of a projection [code]projection.inverse() * vector[/code] can be used instead. See [method Projection.inverse]. |
| 328 | </description> |
| 329 | </operator> |
| 330 | <operator name="operator *"> |
| 331 | <return type="Vector4" /> |
| 332 | <param index="0" name="right" type="Vector4" /> |
| 333 | <description> |
| 334 | Multiplies each component of the [Vector4] by the components of the given [Vector4]. |
| 335 | [codeblock] |
| 336 | print(Vector4(10, 20, 30, 40) * Vector4(3, 4, 5, 6)) # Prints (30.0, 80.0, 150.0, 240.0) |
| 337 | [/codeblock] |
| 338 | </description> |
| 339 | </operator> |
| 340 | <operator name="operator *"> |
| 341 | <return type="Vector4" /> |
| 342 | <param index="0" name="right" type="float" /> |
| 343 | <description> |
| 344 | Multiplies each component of the [Vector4] by the given [float]. |
| 345 | [codeblock] |
| 346 | print(Vector4(10, 20, 30, 40) * 2) # Prints (20.0, 40.0, 60.0, 80.0) |
| 347 | [/codeblock] |
| 348 | </description> |
| 349 | </operator> |
| 350 | <operator name="operator *"> |
| 351 | <return type="Vector4" /> |
| 352 | <param index="0" name="right" type="int" /> |
| 353 | <description> |
| 354 | Multiplies each component of the [Vector4] by the given [int]. |
| 355 | </description> |
| 356 | </operator> |
| 357 | <operator name="operator +"> |
| 358 | <return type="Vector4" /> |
| 359 | <param index="0" name="right" type="Vector4" /> |
| 360 | <description> |
| 361 | Adds each component of the [Vector4] by the components of the given [Vector4]. |
| 362 | [codeblock] |
| 363 | print(Vector4(10, 20, 30, 40) + Vector4(3, 4, 5, 6)) # Prints (13.0, 24.0, 35.0, 46.0) |
| 364 | [/codeblock] |
| 365 | </description> |
| 366 | </operator> |
| 367 | <operator name="operator -"> |
| 368 | <return type="Vector4" /> |
| 369 | <param index="0" name="right" type="Vector4" /> |
| 370 | <description> |
| 371 | Subtracts each component of the [Vector4] by the components of the given [Vector4]. |
| 372 | [codeblock] |
| 373 | print(Vector4(10, 20, 30, 40) - Vector4(3, 4, 5, 6)) # Prints (7.0, 16.0, 25.0, 34.0) |
| 374 | [/codeblock] |
| 375 | </description> |
| 376 | </operator> |
| 377 | <operator name="operator /"> |
| 378 | <return type="Vector4" /> |
| 379 | <param index="0" name="right" type="Vector4" /> |
| 380 | <description> |
| 381 | Divides each component of the [Vector4] by the components of the given [Vector4]. |
| 382 | [codeblock] |
| 383 | print(Vector4(10, 20, 30, 40) / Vector4(2, 5, 3, 4)) # Prints (5.0, 4.0, 10.0, 10.0) |
| 384 | [/codeblock] |
| 385 | </description> |
| 386 | </operator> |
| 387 | <operator name="operator /"> |
| 388 | <return type="Vector4" /> |
| 389 | <param index="0" name="right" type="float" /> |
| 390 | <description> |
| 391 | Divides each component of the [Vector4] by the given [float]. |
| 392 | [codeblock] |
| 393 | print(Vector4(10, 20, 30, 40) / 2) # Prints (5.0, 10.0, 15.0, 20.0) |
| 394 | [/codeblock] |
| 395 | </description> |
| 396 | </operator> |
| 397 | <operator name="operator /"> |
| 398 | <return type="Vector4" /> |
| 399 | <param index="0" name="right" type="int" /> |
| 400 | <description> |
| 401 | Divides each component of the [Vector4] by the given [int]. |
| 402 | </description> |
| 403 | </operator> |
| 404 | <operator name="operator <"> |
| 405 | <return type="bool" /> |
| 406 | <param index="0" name="right" type="Vector4" /> |
| 407 | <description> |
| 408 | Compares two [Vector4] 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. |
| 409 | [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included. |
| 410 | </description> |
| 411 | </operator> |
| 412 | <operator name="operator <="> |
| 413 | <return type="bool" /> |
| 414 | <param index="0" name="right" type="Vector4" /> |
| 415 | <description> |
| 416 | Compares two [Vector4] 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. |
| 417 | [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included. |
| 418 | </description> |
| 419 | </operator> |
| 420 | <operator name="operator =="> |
| 421 | <return type="bool" /> |
| 422 | <param index="0" name="right" type="Vector4" /> |
| 423 | <description> |
| 424 | Returns [code]true[/code] if the vectors are exactly equal. |
| 425 | [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable. |
| 426 | [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included. |
| 427 | </description> |
| 428 | </operator> |
| 429 | <operator name="operator >"> |
| 430 | <return type="bool" /> |
| 431 | <param index="0" name="right" type="Vector4" /> |
| 432 | <description> |
| 433 | Compares two [Vector4] 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. |
| 434 | [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included. |
| 435 | </description> |
| 436 | </operator> |
| 437 | <operator name="operator >="> |
| 438 | <return type="bool" /> |
| 439 | <param index="0" name="right" type="Vector4" /> |
| 440 | <description> |
| 441 | Compares two [Vector4] 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. |
| 442 | [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included. |
| 443 | </description> |
| 444 | </operator> |
| 445 | <operator name="operator []"> |
| 446 | <return type="float" /> |
| 447 | <param index="0" name="index" type="int" /> |
| 448 | <description> |
| 449 | 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]. |
| 450 | </description> |
| 451 | </operator> |
| 452 | <operator name="operator unary+"> |
| 453 | <return type="Vector4" /> |
| 454 | <description> |
| 455 | 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. |
| 456 | </description> |
| 457 | </operator> |
| 458 | <operator name="operator unary-"> |
| 459 | <return type="Vector4" /> |
| 460 | <description> |
| 461 | Returns the negative value of the [Vector4]. This is the same as writing [code]Vector4(-v.x, -v.y, -v.z, -v.w)[/code]. This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative. |
| 462 | </description> |
| 463 | </operator> |
| 464 | </operators> |
| 465 | </class> |