Compatibility note for 1.0 release and PR#48 test
This commit is contained in:
parent
1000f1d6e5
commit
ddb80f48e6
@ -15,4 +15,4 @@ Clone the repository and require it, or if you prefer luarocks: `$ luarocks inst
|
||||
|
||||
# Versions
|
||||
|
||||
This library has a major compatibility break at version 1.0. Up to version 0.10, composition a*b means "apply b, then a" for quaternions and "apply a, then b" for matrices. Starting with version 1.0, the two are consistent and matrix a*b means "apply b, then a".
|
||||
This library has a major compatibility break at version 1.0. Up to version 0.10, composition a*b means "apply b, then a" for quaternions and "apply a, then b" for matrices. Now as of version 1.0, the two are consistent and matrix a*b means "apply b, then a".
|
||||
|
@ -184,6 +184,32 @@ describe("mat4:", function()
|
||||
assert.is.equal(c[4], d[4])
|
||||
end)
|
||||
|
||||
it("verifies mat4 composition order", function()
|
||||
local a = mat4 {
|
||||
1, 5, 9, 13,
|
||||
2, 6, 10, 14,
|
||||
3, 7, 11, 15,
|
||||
4, 8, 12, 16
|
||||
}
|
||||
local b = mat4 {
|
||||
2, 3, 5, 7,
|
||||
11, 13, 17, 19,
|
||||
23, 29, 31, 37,
|
||||
41, 43, 47, 53
|
||||
}
|
||||
local c = mat4():mul(a, b)
|
||||
local d = a * b
|
||||
|
||||
local v = { 10, 20, 30, 40 }
|
||||
|
||||
local cv = c * v
|
||||
local abv = a*(b*v)
|
||||
|
||||
assert.is.equal(cv.x, abv.x) -- Verify (a*b)*v == a*(b*v)
|
||||
assert.is.equal(cv.y, abv.y)
|
||||
assert.is.equal(cv.z, abv.z)
|
||||
end)
|
||||
|
||||
it("scales a matrix", function()
|
||||
local a = mat4():scale(mat4(), vec3(5, 5, 5))
|
||||
assert.is.equal(5, a[1])
|
||||
|
@ -1,6 +1,7 @@
|
||||
local quat = require "modules.quat"
|
||||
local vec3 = require "modules.vec3"
|
||||
local utils = require "modules.utils"
|
||||
local constants = require "modules.constants"
|
||||
|
||||
describe("quat:", function()
|
||||
it("creates an identity quaternion", function()
|
||||
@ -125,6 +126,19 @@ describe("quat:", function()
|
||||
assert.is.equal(b, c)
|
||||
end)
|
||||
|
||||
it("verifies quat composition order", function()
|
||||
local a = quat(2, 3, 4, 1):normalize() -- Only the normal quaternions represent rotations
|
||||
local b = quat(3, 6, 9, 1):normalize()
|
||||
local c = a * b
|
||||
|
||||
local v = vec3(3, 4, 5)
|
||||
|
||||
local cv = c * v
|
||||
local abv = a * (b * v)
|
||||
|
||||
assert.is_true((abv - cv):len() < 1e-07) -- Verify (a*b)*v == a*(b*v) within an epsilon
|
||||
end)
|
||||
|
||||
it("multiplies a quaternion by an exponent of 0", function()
|
||||
local a = quat(2, 3, 4, 1):normalize()
|
||||
local e = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user