fix typo
This commit is contained in:
parent
e8228f8c8a
commit
b122e4d726
@ -321,8 +321,8 @@ end
|
||||
|
||||
--- Multiply two matrices.
|
||||
-- @tparam mat4 out Matrix to store the result
|
||||
-- @tparam mat4 a Left hand operant
|
||||
-- @tparam mat4 b Right hand operant
|
||||
-- @tparam mat4 a Left hand operand
|
||||
-- @tparam mat4 b Right hand operand
|
||||
-- @treturn mat4 out
|
||||
function mat4.mul(out, a, b)
|
||||
tm4[1] = a[1] * b[1] + a[2] * b[5] + a[3] * b[9] + a[4] * b[13]
|
||||
@ -351,8 +351,8 @@ end
|
||||
|
||||
--- Multiply a matrix and a vec4.
|
||||
-- @tparam mat4 out Matrix to store the result
|
||||
-- @tparam mat4 a Left hand operant
|
||||
-- @tparam table b Right hand operant
|
||||
-- @tparam mat4 a Left hand operand
|
||||
-- @tparam table b Right hand operand
|
||||
-- @treturn mat4 out
|
||||
function mat4.mul_vec4(out, a, b)
|
||||
tv4[1] = b[1] * a[1] + b[2] * a[5] + b [3] * a[9] + b[4] * a[13]
|
||||
@ -812,13 +812,13 @@ function mat4_mt.__eq(a, b)
|
||||
end
|
||||
|
||||
function mat4_mt.__mul(a, b)
|
||||
assert(mat4.is_mat4(a), "__mul: Wrong argument type for left hand operant. (<cpml.mat4> expected)")
|
||||
assert(mat4.is_mat4(a), "__mul: Wrong argument type for left hand operand. (<cpml.mat4> expected)")
|
||||
|
||||
if vec3.is_vec3(b) then
|
||||
return vec3(mat4.mul_vec4({}, a, { b.x, b.y, b.z, 1 }))
|
||||
end
|
||||
|
||||
assert(mat4.is_mat4(b) or #b == 4, "__mul: Wrong argument type for right hand operant. (<cpml.mat4> or table #4 expected)")
|
||||
assert(mat4.is_mat4(b) or #b == 4, "__mul: Wrong argument type for right hand operand. (<cpml.mat4> or table #4 expected)")
|
||||
|
||||
if mat4.is_mat4(b) then
|
||||
return new():mul(a, b)
|
||||
|
@ -108,8 +108,8 @@ function quat.clone(a)
|
||||
end
|
||||
|
||||
--- Add two quaternions.
|
||||
-- @tparam quat a Left hand operant
|
||||
-- @tparam quat b Right hand operant
|
||||
-- @tparam quat a Left hand operand
|
||||
-- @tparam quat b Right hand operand
|
||||
-- @treturn quat out
|
||||
function quat.add(a, b)
|
||||
return new(
|
||||
@ -121,8 +121,8 @@ function quat.add(a, b)
|
||||
end
|
||||
|
||||
--- Subtract a quaternion from another.
|
||||
-- @tparam quat a Left hand operant
|
||||
-- @tparam quat b Right hand operant
|
||||
-- @tparam quat a Left hand operand
|
||||
-- @tparam quat b Right hand operand
|
||||
-- @treturn quat out
|
||||
function quat.sub(a, b)
|
||||
return new(
|
||||
@ -134,8 +134,8 @@ function quat.sub(a, b)
|
||||
end
|
||||
|
||||
--- Multiply two quaternions.
|
||||
-- @tparam quat a Left hand operant
|
||||
-- @tparam quat b Right hand operant
|
||||
-- @tparam quat a Left hand operand
|
||||
-- @tparam quat b Right hand operand
|
||||
-- @treturn quat out
|
||||
function quat.mul(a, b)
|
||||
return new(
|
||||
@ -147,8 +147,8 @@ function quat.mul(a, b)
|
||||
end
|
||||
|
||||
--- Multiply a quaternion and a vec3.
|
||||
-- @tparam quat a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam quat a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn quat out
|
||||
function quat.mul_vec3(a, b)
|
||||
qv.x = a.x
|
||||
@ -193,8 +193,8 @@ function quat.normalize(a)
|
||||
end
|
||||
|
||||
--- Get the dot product of two quaternions.
|
||||
-- @tparam quat a Left hand operant
|
||||
-- @tparam quat b Right hand operant
|
||||
-- @tparam quat a Left hand operand
|
||||
-- @tparam quat b Right hand operand
|
||||
-- @treturn number dot
|
||||
function quat.dot(a, b)
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w
|
||||
@ -215,8 +215,8 @@ function quat.len2(a)
|
||||
end
|
||||
|
||||
--- Multiply a quaternion by a scalar.
|
||||
-- @tparam quat a Left hand operant
|
||||
-- @tparam number s Right hand operant
|
||||
-- @tparam quat a Left hand operand
|
||||
-- @tparam number s Right hand operand
|
||||
-- @treturn quat out
|
||||
function quat.scale(a, s)
|
||||
return new(
|
||||
@ -271,8 +271,8 @@ function quat.reciprocal(a)
|
||||
end
|
||||
|
||||
--- Lerp between two quaternions.
|
||||
-- @tparam quat a Left hand operant
|
||||
-- @tparam quat b Right hand operant
|
||||
-- @tparam quat a Left hand operand
|
||||
-- @tparam quat b Right hand operand
|
||||
-- @tparam number s Step value
|
||||
-- @treturn quat out
|
||||
function quat.lerp(a, b, s)
|
||||
@ -280,8 +280,8 @@ function quat.lerp(a, b, s)
|
||||
end
|
||||
|
||||
--- Slerp between two quaternions.
|
||||
-- @tparam quat a Left hand operant
|
||||
-- @tparam quat b Right hand operant
|
||||
-- @tparam quat a Left hand operand
|
||||
-- @tparam quat b Right hand operand
|
||||
-- @tparam number s Step value
|
||||
-- @treturn quat out
|
||||
function quat.slerp(a, b, s)
|
||||
@ -416,20 +416,20 @@ function quat_mt.__eq(a,b)
|
||||
end
|
||||
|
||||
function quat_mt.__add(a, b)
|
||||
assert(quat.is_quat(a), "__add: Wrong argument type for left hand operant. (<cpml.quat> expected)")
|
||||
assert(quat.is_quat(b), "__add: Wrong argument type for right hand operant. (<cpml.quat> expected)")
|
||||
assert(quat.is_quat(a), "__add: Wrong argument type for left hand operand. (<cpml.quat> expected)")
|
||||
assert(quat.is_quat(b), "__add: Wrong argument type for right hand operand. (<cpml.quat> expected)")
|
||||
return a:add(b)
|
||||
end
|
||||
|
||||
function quat_mt.__sub(a, b)
|
||||
assert(quat.is_quat(a), "__sub: Wrong argument type for left hand operant. (<cpml.quat> expected)")
|
||||
assert(quat.is_quat(b), "__sub: Wrong argument type for right hand operant. (<cpml.quat> expected)")
|
||||
assert(quat.is_quat(a), "__sub: Wrong argument type for left hand operand. (<cpml.quat> expected)")
|
||||
assert(quat.is_quat(b), "__sub: Wrong argument type for right hand operand. (<cpml.quat> expected)")
|
||||
return a:sub(b)
|
||||
end
|
||||
|
||||
function quat_mt.__mul(a, b)
|
||||
assert(quat.is_quat(a), "__mul: Wrong argument type for left hand operant. (<cpml.quat> expected)")
|
||||
assert(quat.is_quat(b) or vec3.is_vec3(b) or type(b) == "number", "__mul: Wrong argument type for right hand operant. (<cpml.quat> or <cpml.vec3> or <number> expected)")
|
||||
assert(quat.is_quat(a), "__mul: Wrong argument type for left hand operand. (<cpml.quat> expected)")
|
||||
assert(quat.is_quat(b) or vec3.is_vec3(b) or type(b) == "number", "__mul: Wrong argument type for right hand operand. (<cpml.quat> or <cpml.vec3> or <number> expected)")
|
||||
|
||||
if quat.is_quat(b) then
|
||||
return a:mul(b)
|
||||
@ -443,8 +443,8 @@ function quat_mt.__mul(a, b)
|
||||
end
|
||||
|
||||
function quat_mt.__pow(a, n)
|
||||
assert(quat.is_quat(a), "__pow: Wrong argument type for left hand operant. (<cpml.quat> expected)")
|
||||
assert(type(n) == "number", "__pow: Wrong argument type for right hand operant. (<number> expected)")
|
||||
assert(quat.is_quat(a), "__pow: Wrong argument type for left hand operand. (<cpml.quat> expected)")
|
||||
assert(type(n) == "number", "__pow: Wrong argument type for right hand operand. (<number> expected)")
|
||||
return a:pow(n)
|
||||
end
|
||||
|
||||
|
@ -85,8 +85,8 @@ function vec2.clone(a)
|
||||
end
|
||||
|
||||
--- Add two vectors.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @treturn vec2 out
|
||||
function vec2.add(a, b)
|
||||
return new(
|
||||
@ -96,8 +96,8 @@ function vec2.add(a, b)
|
||||
end
|
||||
|
||||
--- Subtract one vector from another.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @treturn vec2 out
|
||||
function vec2.sub(a, b)
|
||||
return new(
|
||||
@ -107,8 +107,8 @@ function vec2.sub(a, b)
|
||||
end
|
||||
|
||||
--- Multiply a vector by another vector.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @treturn vec2 out
|
||||
function vec2.mul(a, b)
|
||||
return new(
|
||||
@ -118,8 +118,8 @@ function vec2.mul(a, b)
|
||||
end
|
||||
|
||||
--- Divide a vector by another vector.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @treturn vec2 out
|
||||
function vec2.div(a, b)
|
||||
return new(
|
||||
@ -147,16 +147,16 @@ function vec2.trim(a, len)
|
||||
end
|
||||
|
||||
--- Get the cross product of two vectors.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @treturn number magnitude
|
||||
function vec2.cross(a, b)
|
||||
return a.x * b.y - a.y * b.x
|
||||
end
|
||||
|
||||
--- Get the dot product of two vectors.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @treturn number dot
|
||||
function vec2.dot(a, b)
|
||||
return a.x * b.x + a.y * b.y
|
||||
@ -177,8 +177,8 @@ function vec2.len2(a)
|
||||
end
|
||||
|
||||
--- Get the distance between two vectors.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @treturn number dist
|
||||
function vec2.dist(a, b)
|
||||
local dx = a.x - b.x
|
||||
@ -187,8 +187,8 @@ function vec2.dist(a, b)
|
||||
end
|
||||
|
||||
--- Get the squared distance between two vectors.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @treturn number dist
|
||||
function vec2.dist2(a, b)
|
||||
local dx = a.x - b.x
|
||||
@ -197,8 +197,8 @@ function vec2.dist2(a, b)
|
||||
end
|
||||
|
||||
--- Scale a vector by a scalar.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam number b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam number b Right hand operand
|
||||
-- @treturn vec2 out
|
||||
function vec2.scale(a, b)
|
||||
return new(
|
||||
@ -256,8 +256,8 @@ function vec2.angle_between(a, b)
|
||||
end
|
||||
|
||||
--- Lerp between two vectors.
|
||||
-- @tparam vec2 a Left hand operant
|
||||
-- @tparam vec2 b Right hand operant
|
||||
-- @tparam vec2 a Left hand operand
|
||||
-- @tparam vec2 b Right hand operand
|
||||
-- @tparam number s Step value
|
||||
-- @treturn vec2 out
|
||||
function vec2.lerp(a, b, s)
|
||||
@ -330,20 +330,20 @@ function vec2_mt.__eq(a, b)
|
||||
end
|
||||
|
||||
function vec2_mt.__add(a, b)
|
||||
assert(vec2.is_vec2(a), "__add: Wrong argument type for left hand operant. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(b), "__add: Wrong argument type for right hand operant. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(a), "__add: Wrong argument type for left hand operand. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(b), "__add: Wrong argument type for right hand operand. (<cpml.vec2> expected)")
|
||||
return a:add(b)
|
||||
end
|
||||
|
||||
function vec2_mt.__sub(a, b)
|
||||
assert(vec2.is_vec2(a), "__add: Wrong argument type for left hand operant. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(b), "__add: Wrong argument type for right hand operant. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(a), "__add: Wrong argument type for left hand operand. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(b), "__add: Wrong argument type for right hand operand. (<cpml.vec2> expected)")
|
||||
return a:sub(b)
|
||||
end
|
||||
|
||||
function vec2_mt.__mul(a, b)
|
||||
assert(vec2.is_vec2(a), "__mul: Wrong argument type for left hand operant. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(b) or type(b) == "number", "__mul: Wrong argument type for right hand operant. (<cpml.vec2> or <number> expected)")
|
||||
assert(vec2.is_vec2(a), "__mul: Wrong argument type for left hand operand. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(b) or type(b) == "number", "__mul: Wrong argument type for right hand operand. (<cpml.vec2> or <number> expected)")
|
||||
|
||||
if vec2.is_vec2(b) then
|
||||
return a:mul(b)
|
||||
@ -353,8 +353,8 @@ function vec2_mt.__mul(a, b)
|
||||
end
|
||||
|
||||
function vec2_mt.__div(a, b)
|
||||
assert(vec2.is_vec2(a), "__div: Wrong argument type for left hand operant. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(b) or type(b) == "number", "__div: Wrong argument type for right hand operant. (<cpml.vec2> or <number> expected)")
|
||||
assert(vec2.is_vec2(a), "__div: Wrong argument type for left hand operand. (<cpml.vec2> expected)")
|
||||
assert(vec2.is_vec2(b) or type(b) == "number", "__div: Wrong argument type for right hand operand. (<cpml.vec2> or <number> expected)")
|
||||
|
||||
if vec2.is_vec2(b) then
|
||||
return a:div(b)
|
||||
|
@ -79,8 +79,8 @@ function vec3.clone(a)
|
||||
end
|
||||
|
||||
--- Add two vectors.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn vec3 out
|
||||
function vec3.add(a, b)
|
||||
return new(
|
||||
@ -91,8 +91,8 @@ function vec3.add(a, b)
|
||||
end
|
||||
|
||||
--- Subtract one vector from another.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn vec3 out
|
||||
function vec3.sub(a, b)
|
||||
return new(
|
||||
@ -103,8 +103,8 @@ function vec3.sub(a, b)
|
||||
end
|
||||
|
||||
--- Multiply a vector by another vectorr.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn vec3 out
|
||||
function vec3.mul(a, b)
|
||||
return new(
|
||||
@ -115,8 +115,8 @@ function vec3.mul(a, b)
|
||||
end
|
||||
|
||||
--- Divide a vector by a scalar.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn vec3 out
|
||||
function vec3.div(a, b)
|
||||
return new(
|
||||
@ -145,8 +145,8 @@ function vec3.trim(a, len)
|
||||
end
|
||||
|
||||
--- Get the cross product of two vectors.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn vec3 out
|
||||
function vec3.cross(a, b)
|
||||
return new(
|
||||
@ -157,8 +157,8 @@ function vec3.cross(a, b)
|
||||
end
|
||||
|
||||
--- Get the dot product of two vectors.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn number dot
|
||||
function vec3.dot(a, b)
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z
|
||||
@ -179,8 +179,8 @@ function vec3.len2(a)
|
||||
end
|
||||
|
||||
--- Get the distance between two vectors.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn number dist
|
||||
function vec3.dist(a, b)
|
||||
local dx = a.x - b.x
|
||||
@ -190,8 +190,8 @@ function vec3.dist(a, b)
|
||||
end
|
||||
|
||||
--- Get the squared distance between two vectors.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @treturn number dist
|
||||
function vec3.dist2(a, b)
|
||||
local dx = a.x - b.x
|
||||
@ -201,8 +201,8 @@ function vec3.dist2(a, b)
|
||||
end
|
||||
|
||||
--- Scale a vector by a scalar.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam number b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam number b Right hand operand
|
||||
-- @treturn vec3 out
|
||||
function vec3.scale(a, b)
|
||||
return new(
|
||||
@ -246,8 +246,8 @@ function vec3.perpendicular(a)
|
||||
end
|
||||
|
||||
--- Lerp between two vectors.
|
||||
-- @tparam vec3 a Left hand operant
|
||||
-- @tparam vec3 b Right hand operant
|
||||
-- @tparam vec3 a Left hand operand
|
||||
-- @tparam vec3 b Right hand operand
|
||||
-- @tparam number s Step value
|
||||
-- @treturn vec3 out
|
||||
function vec3.lerp(a, b, s)
|
||||
@ -311,20 +311,20 @@ function vec3_mt.__eq(a, b)
|
||||
end
|
||||
|
||||
function vec3_mt.__add(a, b)
|
||||
assert(vec3.is_vec3(a), "__add: Wrong argument type for left hand operant. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(b), "__add: Wrong argument type for right hand operant. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(a), "__add: Wrong argument type for left hand operand. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(b), "__add: Wrong argument type for right hand operand. (<cpml.vec3> expected)")
|
||||
return a:add(b)
|
||||
end
|
||||
|
||||
function vec3_mt.__sub(a, b)
|
||||
assert(vec3.is_vec3(a), "__sub: Wrong argument type for left hand operant. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(b), "__sub: Wrong argument type for right hand operant. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(a), "__sub: Wrong argument type for left hand operand. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(b), "__sub: Wrong argument type for right hand operand. (<cpml.vec3> expected)")
|
||||
return a:sub(b)
|
||||
end
|
||||
|
||||
function vec3_mt.__mul(a, b)
|
||||
assert(vec3.is_vec3(a), "__mul: Wrong argument type for left hand operant. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(b) or type(b) == "number", "__mul: Wrong argument type for right hand operant. (<cpml.vec3> or <number> expected)")
|
||||
assert(vec3.is_vec3(a), "__mul: Wrong argument type for left hand operand. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(b) or type(b) == "number", "__mul: Wrong argument type for right hand operand. (<cpml.vec3> or <number> expected)")
|
||||
|
||||
if vec3.is_vec3(b) then
|
||||
return a:mul(b)
|
||||
@ -334,8 +334,8 @@ function vec3_mt.__mul(a, b)
|
||||
end
|
||||
|
||||
function vec3_mt.__div(a, b)
|
||||
assert(vec3.is_vec3(a), "__div: Wrong argument type for left hand operant. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(b) or type(b) == "number", "__div: Wrong argument type for right hand operant. (<cpml.vec3> or <number> expected)")
|
||||
assert(vec3.is_vec3(a), "__div: Wrong argument type for left hand operand. (<cpml.vec3> expected)")
|
||||
assert(vec3.is_vec3(b) or type(b) == "number", "__div: Wrong argument type for right hand operand. (<cpml.vec3> or <number> expected)")
|
||||
|
||||
if vec3.is_vec3(b) then
|
||||
return a:div(b)
|
||||
|
Loading…
x
Reference in New Issue
Block a user