Vec3

From Crumbled World Wiki

Example Code

local a = Vec3(6,8,0)
local b = a + Vec3(-2,-2, 1) * 2
print("Vec3(" . .b.x .. ", " .. b.y .. ", " .. b.z .. ")")    --print Vec3(2.0, 4.0, 2.0)
a:normalize()
print(tostring(a))    --print Vec3(0.6, 0.8, 0.0)

Members

type variable description
float x
float y
float z

Constructor

function description
Vec3(float value)
Vec3(float x, float y, float z)
Vec3(Vec2 vec, float z)
Vec3(Vec3 vector)
Vec3()

Functions

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

Operators

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