Vec4
From Crumbled World Wiki
Example Code
local a = Vec4(6, 8, 0, 0)
local b = a + Vec4(-2,-2, 1, 0) * 2
print(b.x..", "..b.y..", "..b.z..", "..b.w) --print 2.0, 4.0, 2.0, 0.0
a:normalize()
print(a.x..", "..a.y..", "..a.z..", "..b.w) --print 0.6, 0.8, 0.0, 0.0
Members
| type | variable | description |
|---|---|---|
| float | x | |
| float | y | |
| float | z | |
| float | w |
Constructor
| function | description |
|---|---|
| Vec4(float x, float y, float z, float w) | |
| Vec4(float value) | |
| Vec4(Vec4 vector) | |
| Vec4(Vec3 vector, float w) | |
| Vec4(Vec2 vector, float z, float w) | |
| Vec4() |
Functions
| return | function | description |
|---|---|---|
| float | dot() | Returns the dot product of this vec with itself. |
| float | dot(Vec4 vector) | Return the dot product of this with vector. |
| float | length() | Returns the length of this vector. |
| negate() | negate the vector. | |
| clear() | set vector to zero. | |
| infinity() | set vector to infinity. | |
| float | normalize() | normalize the vector and return the old length. |
| Vec4 | normalizeV() | return a copy and normalize the return vec. |
| interPolate(Vec4 vector1, Vec4 vector2, float weight) | Inter polate a vector bettwen two values. weight 0 returns vector1 and at weight 1 vector2 is returned | |
| Vec4 | interPolateV(Vec4 vector1, Vec4 vector2, float weight) | returns a Inter polate a vector bettwen two values. weight 0 returns vector1 and at weight 1 vector2 is returned |
| bool | isZero() | returns true when vector length is zero |
| bool | isInfinity() | returns true when vetor length is infinity |
| minimize(Vec4 vector) | Keep the minimum x and y value from this vector and vec | |
| maximize(Vec4 vector) | Keep the maximum x and y value from this vector and vec | |
| Vec3 | toVec3() | return Vec3(x, y ,z) |
| Vec2 | toVec2() | return Vec2(x, y) |
Operators
| return | function | description |
|---|---|---|
| Vec4 | Vec4 + Vec4 | |
| Vec4 | Vec4 - Vec4 | |
| Vec4 | Vec4 * float | |
| Vec4 | Vec4 / float | |
| bool | Vec4 == float |