TouchOSC provides 2,3 and 4 component vector types as Vec2
Vec3
Vec4
objects.
vec2.x
vec3.x
vec4.x
The x component of the vector.
vec2.y
vec3.y
vec4.y
The y component of the vector.
vec3.z
vec4.z
The z component of the vector.
vec4.w
The w component of the vector.
function Vec2() -- [1]
function Vec2(vec2) -- [2]
function Vec2(number) -- [3]
function Vec2(number, number) -- [4]
function Vec3() -- [1]
function Vec3(vec3) -- [2]
function Vec3(number) -- [3]
function Vec3(number, number, number) -- [4]
function Vec4() -- [1]
function Vec4(vec4) -- [2]
function Vec4(number) -- [3]
function Vec4(number, number, number, number) -- [4]
Returns a new vector object with
0.0
.
function length()
-- example
local v = Vec2(1,0)
local l = v:length()
print(l)
> 1
Returns the length of the vector
function normalize()
-- example
local v = Vec2(1,1)
local n = v:normalize()
Returns a new vector that is the normalized vector
-- multiplication
vector * vector
vector * number
-- division
vector / vector
vector / number
-- addition
vector + vector
vector + number
-- subtraction
vector - vector
vector - number
All operators operate component-wise and return a new vector object.
We use cookies to deliver website content. By continuing without changing your preferences, you agree to our use of cookies.