Vec2

From Crumbled World Wiki
Revision as of 07:53, 6 July 2025 by Anders (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Example

local vec = Vec2(2,9.2)
local anotherVec = vec + (Vec2(-2,-2) * 2)

Members

type variable description
float x
float y

Constructor

function description
Vec2(float x, float y)
Vec2(float value)
Vec2(Vec2 vector)
Vec2()

Functions

return function description
float dot() Returns the dot product of this vec with itself.
float dot(Vec2 vector) Return the dot product of this with vector.
float angle(Vec2 vector) Return the angle bettwen the two vectors.
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.
Vec2 normalizeV() Return a copy and normalize the return vec.
interPolate(Vec2 vector1, Vec2 vector2, float weight) Inter polate a vector bettwen two values. weight 0 returns vector1 and at weight 1 vector2 is returned
Vec2 interPolateV(Vec2 vector1, Vec2 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(Vec2 vector) Keep the minimum x and y value from this vector and vec.
maximize(Vec2 vector) Keep the maximum x and y value from this vector and vec.

Operators

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