Difference between revisions of "Vector library"

From GiderosMobile
(Created page with "__NOTOC__ <!-- GIDEROSOBJ:vector --> '''Supported platforms:''' File:Platform android.pngFile:Platform ios.pngFile:Platform mac.pngFile:Platform pc.pngFile:P...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
<!-- GIDEROSOBJ:vector -->
 
<!-- GIDEROSOBJ:vector -->
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform linux.png]]<br/>
+
{{PLATFORMS_ALL}}
 
'''Available since:''' Gideros 2026.1<br/>
 
'''Available since:''' Gideros 2026.1<br/>
  
 
=== Description ===
 
=== Description ===
This library implements functionality for the vector type in addition to the built-in primitive operator support. Default configuration uses vectors with 3 components (x, y, and z). If the 4-wide mode is enabled by setting the LUA_VECTOR_SIZE VM configuration to 4, vectors get an additional w component.
+
This library implements functionality for the vector type in addition to the built-in primitive operator support. Default Gideros configuration uses vectors with 3 components (x, y, and z).
 +
 
 +
Individual vector components can be accessed using the fields x or X, y or Y, z or Z. Since vector values are immutable, writes to individual components are not supported.
  
 
=== Reference ===
 
=== Reference ===
Line 13: Line 15:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
=== Methods ===
[[dofile]] ''executes as Lua chunk, default stdin, returns value''<br/><!--GIDEROSMTD:dofile(filename) executes as Lua chunk, default stdin, returns value-->
+
[[vector.create]] ''creates a new vector with the given component values''<br/><!--GIDEROSMTD:vector.create(x,y,z) creates a new vector with the given component values-->
[[error]] ''terminates protected func, never returns''<br/><!--GIDEROSMTD:error(message,level) terminates protected func, never returns-->
+
[[vector.cross]] ''computes the cross product of two vectors''<br/><!--GIDEROSMTD:vector.cross(vec1,vec2) computes the cross product of two vectors-->
 +
[[vector.magnitude]] ''calculates the magnitude of a given vector''<br/><!--GIDEROSMTD:vector.magnitude(vec) calculates the magnitude of a given vector-->
 +
[[vector.normalize]] ''computes the normalized version of a given vector''<br/><!--GIDEROSMTD:vector.normalize(vec) computes the normalized version of a given vector-->
 +
[[vector.one]] ''constant vector with all components set to 1''<br/><!--GIDEROSMTD:vector.one constant vector with all components set to 1-->
 +
[[vector.zero]] ''constant vector with all components set to 0''<br/><!--GIDEROSMTD:vector.zero constant vector with all components set to 0-->
  
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|

Latest revision as of 14:29, 1 February 2026

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform winrt.pngPlatform win32.pngPlatform linux.pngPlatform html5.png
Available since: Gideros 2026.1

Description

This library implements functionality for the vector type in addition to the built-in primitive operator support. Default Gideros configuration uses vectors with 3 components (x, y, and z).

Individual vector components can be accessed using the fields x or X, y or Y, z or Z. Since vector values are immutable, writes to individual components are not supported.

Reference

https://luau.org/library/#vector-library

Methods

vector.create creates a new vector with the given component values
vector.cross computes the cross product of two vectors
vector.magnitude calculates the magnitude of a given vector
vector.normalize computes the normalized version of a given vector
vector.one constant vector with all components set to 1
vector.zero constant vector with all components set to 0

Events

Constants