mirror of
https://github.com/orange-cpp/omath.git
synced 2026-04-18 18:23:26 +00:00
migrated to sol2
decomposed method added vector2, vector4 refactored tests added opengl engine to lua added other engines added source tests removed tons of lua files
This commit is contained in:
29
tests/lua/vector2_test.lua
Normal file
29
tests/lua/vector2_test.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
local a = omath.Vec2.new(1, 2)
|
||||
local b = omath.Vec2.new(10, 20)
|
||||
|
||||
-- Operators
|
||||
local c = a + b
|
||||
local d = a - b
|
||||
local e = a * 2.0
|
||||
local f = -a
|
||||
print("a + b = " .. tostring(c))
|
||||
print("a - b = " .. tostring(d))
|
||||
print("a * 2 = " .. tostring(e))
|
||||
print("-a = " .. tostring(f))
|
||||
print("a == Vec2(1,2): " .. tostring(a == omath.Vec2.new(1, 2)))
|
||||
print("a < b: " .. tostring(a < b))
|
||||
|
||||
-- Field access + mutation
|
||||
print("c.x = " .. c.x .. ", c.y = " .. c.y)
|
||||
c.x = 99
|
||||
print("c.x after mutation = " .. c.x)
|
||||
|
||||
-- Methods
|
||||
print("a:length() = " .. a:length())
|
||||
print("a:length_sqr() = " .. a:length_sqr())
|
||||
print("a:normalized() = " .. tostring(a:normalized()))
|
||||
print("a:dot(b) = " .. a:dot(b))
|
||||
print("a:distance_to(b) = " .. a:distance_to(b))
|
||||
print("a:distance_to_sqr(b) = " .. a:distance_to_sqr(b))
|
||||
print("a:sum() = " .. a:sum())
|
||||
print("a:abs() = " .. tostring(a:abs()))
|
||||
Reference in New Issue
Block a user