Vec3

From MaratisWiki
(Difference between revisions)
Jump to: navigation, search
m
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
Minimal vector manipulation for 3d vector, compatible with the current table system :
+
{{lua-function|vec3|x, y, z}}
 +
 
 +
Minimal vector manipulation for 3d vector, compatible with the current table system.
 +
 
 +
{{lua-function-param|x|the ''x'' component of the vector}}
 +
{{lua-function-param|y|the ''y'' component of the vector}}
 +
{{lua-function-param|z|the ''z'' component of the vector}}
  
 
  vec = vec3(x, y, z)
 
  vec = vec3(x, y, z)
  
allowing basic math (addition, multiplication etc), for example :
+
{{example|Allowing basic math (addition, multiplication etc).}}
  
 
  pos = (getPosition(object) + vec3(1, 0, 0)) * 2
 
  pos = (getPosition(object) + vec3(1, 0, 0)) * 2
 
+
 
  -- it's still a table like before :
 
  -- it's still a table like before :
 
  x = pos[1]
 
  x = pos[1]
Line 13: Line 19:
  
 
[[Category:Lua scripting]]
 
[[Category:Lua scripting]]
 +
[[Category:Lua function]]
 +
[[Category:3D math]]

Latest revision as of 19:53, 8 February 2014

vec3(x, y, z)

Minimal vector manipulation for 3d vector, compatible with the current table system.

  • x : the x component of the vector
  • y : the y component of the vector
  • z : the z component of the vector
vec = vec3(x, y, z)

Example: Allowing basic math (addition, multiplication etc).

pos = (getPosition(object) + vec3(1, 0, 0)) * 2

-- it's still a table like before :
x = pos[1]
y = pos[2]
z = pos[3]
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox