Vec2i

From Crumbled World Wiki

Example Code

local a = Vec2(6,8)
local b = a + Vec2i(-2,-2) * 2
print(b.x .. ", " .. b.y)    --print 2, 4

Members

type variable description
float x
float y

Constructor

function description
Vec2i(float x, float y)
Vec2i(float xy)
Vec2i(Vec2i vactor)
Vec2i()

Functions

return function description
float dot() Returns the dot product of this vec with itself.
float dot(Vec2i vector) Return the dot product of this with vector.
float length() Returns the length of this vector.
float getXYDist() Returns x + y.
negate() Negate the vector.
clear() Set vector to zero.
infinity() Set vector to infinity.
float normalize() Normalize the vector and return the old length.
Vec2i normalizeV() Return a copy and normalize the return vec.
interPolate(Vec2i vector1, Vec2i vector2, float weight) Inter polate a vector bettwen two values. weight 0 returns vector1 and at weight 1 vector2 is returned
Vec2i interPolateV(Vec2i vector1, Vec2i vector2, float weight) Returns a Inter polate a vector bettwen two values. weight 0 returns vector1 and at weight 1 vector2 is returned

Return (vector1 * weight) + (vector2 * (1-weight));

bool isZero() Returns true when vector length is zero
bool isInfinity() Returns true when vetor length is infinity
minimize(Vec2i vector) Keep the minimum x and y value from this vector and vec
maximize(Vec2i vector) Keep the maximum x and y value from this vector and vec

Operators

return function description
Vec2i Vec2i + Vec2i
Vec2i Vec2i - Vec2i
Vec2i Vec2i * float
Vec2i Vec2i / float
bool Vec2i == float