2
0

vector_spec.lua 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. _G.vector = {}
  2. dofile("builtin/common/vector.lua")
  3. describe("vector", function()
  4. describe("new()", function()
  5. it("constructs", function()
  6. assert.same({x = 0, y = 0, z = 0}, vector.new())
  7. assert.same({x = 1, y = 2, z = 3}, vector.new(1, 2, 3))
  8. assert.same({x = 3, y = 2, z = 1}, vector.new({x = 3, y = 2, z = 1}))
  9. assert.is_true(vector.check(vector.new()))
  10. assert.is_true(vector.check(vector.new(1, 2, 3)))
  11. assert.is_true(vector.check(vector.new({x = 3, y = 2, z = 1})))
  12. local input = vector.new({ x = 3, y = 2, z = 1 })
  13. local output = vector.new(input)
  14. assert.same(input, output)
  15. assert.equal(input, output)
  16. assert.is_false(rawequal(input, output))
  17. assert.equal(input, input:new())
  18. end)
  19. it("throws on invalid input", function()
  20. assert.has.errors(function()
  21. vector.new({ x = 3 })
  22. end)
  23. assert.has.errors(function()
  24. vector.new({ d = 3 })
  25. end)
  26. end)
  27. end)
  28. it("zero()", function()
  29. assert.same({x = 0, y = 0, z = 0}, vector.zero())
  30. assert.same(vector.new(), vector.zero())
  31. assert.equal(vector.new(), vector.zero())
  32. assert.is_true(vector.check(vector.zero()))
  33. end)
  34. it("copy()", function()
  35. local v = vector.new(1, 2, 3)
  36. assert.same(v, vector.copy(v))
  37. assert.same(vector.new(v), vector.copy(v))
  38. assert.equal(vector.new(v), vector.copy(v))
  39. assert.is_true(vector.check(vector.copy(v)))
  40. end)
  41. it("indexes", function()
  42. local some_vector = vector.new(24, 42, 13)
  43. assert.equal(24, some_vector[1])
  44. assert.equal(24, some_vector.x)
  45. assert.equal(42, some_vector[2])
  46. assert.equal(42, some_vector.y)
  47. assert.equal(13, some_vector[3])
  48. assert.equal(13, some_vector.z)
  49. some_vector[1] = 100
  50. assert.equal(100, some_vector.x)
  51. some_vector.x = 101
  52. assert.equal(101, some_vector[1])
  53. some_vector[2] = 100
  54. assert.equal(100, some_vector.y)
  55. some_vector.y = 102
  56. assert.equal(102, some_vector[2])
  57. some_vector[3] = 100
  58. assert.equal(100, some_vector.z)
  59. some_vector.z = 103
  60. assert.equal(103, some_vector[3])
  61. end)
  62. it("direction()", function()
  63. local a = vector.new(1, 0, 0)
  64. local b = vector.new(1, 42, 0)
  65. assert.equal(vector.new(0, 1, 0), vector.direction(a, b))
  66. assert.equal(vector.new(0, 1, 0), a:direction(b))
  67. end)
  68. it("distance()", function()
  69. local a = vector.new(1, 0, 0)
  70. local b = vector.new(3, 42, 9)
  71. assert.is_true(math.abs(43 - vector.distance(a, b)) < 1.0e-12)
  72. assert.is_true(math.abs(43 - a:distance(b)) < 1.0e-12)
  73. assert.equal(0, vector.distance(a, a))
  74. assert.equal(0, b:distance(b))
  75. end)
  76. it("length()", function()
  77. local a = vector.new(0, 0, -23)
  78. assert.equal(0, vector.length(vector.new()))
  79. assert.equal(23, vector.length(a))
  80. assert.equal(23, a:length())
  81. end)
  82. it("normalize()", function()
  83. local a = vector.new(0, 0, -23)
  84. assert.equal(vector.new(0, 0, -1), vector.normalize(a))
  85. assert.equal(vector.new(0, 0, -1), a:normalize())
  86. assert.equal(vector.new(), vector.normalize(vector.new()))
  87. end)
  88. it("floor()", function()
  89. local a = vector.new(0.1, 0.9, -0.5)
  90. assert.equal(vector.new(0, 0, -1), vector.floor(a))
  91. assert.equal(vector.new(0, 0, -1), a:floor())
  92. end)
  93. it("round()", function()
  94. local a = vector.new(0.1, 0.9, -0.5)
  95. assert.equal(vector.new(0, 1, -1), vector.round(a))
  96. assert.equal(vector.new(0, 1, -1), a:round())
  97. end)
  98. it("apply()", function()
  99. local i = 0
  100. local f = function(x)
  101. i = i + 1
  102. return x + i
  103. end
  104. local a = vector.new(0.1, 0.9, -0.5)
  105. assert.equal(vector.new(1, 1, 0), vector.apply(a, math.ceil))
  106. assert.equal(vector.new(1, 1, 0), a:apply(math.ceil))
  107. assert.equal(vector.new(0.1, 0.9, 0.5), vector.apply(a, math.abs))
  108. assert.equal(vector.new(0.1, 0.9, 0.5), a:apply(math.abs))
  109. assert.equal(vector.new(1.1, 2.9, 2.5), vector.apply(a, f))
  110. assert.equal(vector.new(4.1, 5.9, 5.5), a:apply(f))
  111. end)
  112. it("combine()", function()
  113. local a = vector.new(1, 2, 3)
  114. local b = vector.new(3, 2, 1)
  115. assert.equal(vector.add(a, b), vector.combine(a, b, function(x, y) return x + y end))
  116. assert.equal(vector.new(3, 2, 3), vector.combine(a, b, math.max))
  117. assert.equal(vector.new(1, 2, 1), vector.combine(a, b, math.min))
  118. end)
  119. it("equals()", function()
  120. local function assertE(a, b)
  121. assert.is_true(vector.equals(a, b))
  122. end
  123. local function assertNE(a, b)
  124. assert.is_false(vector.equals(a, b))
  125. end
  126. assertE({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
  127. assertE({x = -1, y = 0, z = 1}, {x = -1, y = 0, z = 1})
  128. assertE({x = -1, y = 0, z = 1}, vector.new(-1, 0, 1))
  129. local a = {x = 2, y = 4, z = -10}
  130. assertE(a, a)
  131. assertNE({x = -1, y = 0, z = 1}, a)
  132. assert.equal(vector.new(1, 2, 3), vector.new(1, 2, 3))
  133. assert.is_true(vector.new(1, 2, 3):equals(vector.new(1, 2, 3)))
  134. assert.not_equal(vector.new(1, 2, 3), vector.new(1, 2, 4))
  135. assert.is_true(vector.new(1, 2, 3) == vector.new(1, 2, 3))
  136. assert.is_false(vector.new(1, 2, 3) == vector.new(1, 3, 3))
  137. end)
  138. it("metatable is same", function()
  139. local a = vector.new()
  140. local b = vector.new(1, 2, 3)
  141. assert.equal(true, vector.check(a))
  142. assert.equal(true, vector.check(b))
  143. assert.equal(vector.metatable, getmetatable(a))
  144. assert.equal(vector.metatable, getmetatable(b))
  145. assert.equal(vector.metatable, a.metatable)
  146. end)
  147. it("sort()", function()
  148. local a = vector.new(1, 2, 3)
  149. local b = vector.new(0.5, 232, -2)
  150. local sorted = {vector.new(0.5, 2, -2), vector.new(1, 232, 3)}
  151. assert.same(sorted, {vector.sort(a, b)})
  152. assert.same(sorted, {a:sort(b)})
  153. end)
  154. it("angle()", function()
  155. assert.equal(math.pi, vector.angle(vector.new(-1, -2, -3), vector.new(1, 2, 3)))
  156. assert.equal(math.pi/2, vector.new(0, 1, 0):angle(vector.new(1, 0, 0)))
  157. end)
  158. it("dot()", function()
  159. assert.equal(-14, vector.dot(vector.new(-1, -2, -3), vector.new(1, 2, 3)))
  160. assert.equal(0, vector.new():dot(vector.new(1, 2, 3)))
  161. end)
  162. it("cross()", function()
  163. local a = vector.new(-1, -2, 0)
  164. local b = vector.new(1, 2, 3)
  165. assert.equal(vector.new(-6, 3, 0), vector.cross(a, b))
  166. assert.equal(vector.new(-6, 3, 0), a:cross(b))
  167. end)
  168. it("offset()", function()
  169. assert.same({x = 41, y = 52, z = 63}, vector.offset(vector.new(1, 2, 3), 40, 50, 60))
  170. assert.equal(vector.new(41, 52, 63), vector.offset(vector.new(1, 2, 3), 40, 50, 60))
  171. assert.equal(vector.new(41, 52, 63), vector.new(1, 2, 3):offset(40, 50, 60))
  172. end)
  173. it("is()", function()
  174. local some_table1 = {foo = 13, [42] = 1, "bar", 2}
  175. local some_table2 = {1, 2, 3}
  176. local some_table3 = {x = 1, 2, 3}
  177. local some_table4 = {1, 2, z = 3}
  178. local old = {x = 1, y = 2, z = 3}
  179. local real = vector.new(1, 2, 3)
  180. assert.is_false(vector.check(nil))
  181. assert.is_false(vector.check(1))
  182. assert.is_false(vector.check(true))
  183. assert.is_false(vector.check("foo"))
  184. assert.is_false(vector.check(some_table1))
  185. assert.is_false(vector.check(some_table2))
  186. assert.is_false(vector.check(some_table3))
  187. assert.is_false(vector.check(some_table4))
  188. assert.is_false(vector.check(old))
  189. assert.is_true(vector.check(real))
  190. assert.is_true(real:check())
  191. end)
  192. it("global pairs", function()
  193. local out = {}
  194. local vec = vector.new(10, 20, 30)
  195. for k, v in pairs(vec) do
  196. out[k] = v
  197. end
  198. assert.same({x = 10, y = 20, z = 30}, out)
  199. end)
  200. it("abusing works", function()
  201. local v = vector.new(1, 2, 3)
  202. v.a = 1
  203. assert.equal(1, v.a)
  204. local a_is_there = false
  205. for key, value in pairs(v) do
  206. if key == "a" then
  207. a_is_there = true
  208. assert.equal(value, 1)
  209. break
  210. end
  211. end
  212. assert.is_true(a_is_there)
  213. end)
  214. it("add()", function()
  215. local a = vector.new(1, 2, 3)
  216. local b = vector.new(1, 4, 3)
  217. local c = vector.new(2, 6, 6)
  218. assert.equal(c, vector.add(a, {x = 1, y = 4, z = 3}))
  219. assert.equal(c, vector.add(a, b))
  220. assert.equal(c, a:add(b))
  221. assert.equal(c, a + b)
  222. assert.equal(c, b + a)
  223. end)
  224. it("subtract()", function()
  225. local a = vector.new(1, 2, 3)
  226. local b = vector.new(2, 4, 3)
  227. local c = vector.new(-1, -2, 0)
  228. assert.equal(c, vector.subtract(a, {x = 2, y = 4, z = 3}))
  229. assert.equal(c, vector.subtract(a, b))
  230. assert.equal(c, a:subtract(b))
  231. assert.equal(c, a - b)
  232. assert.equal(c, -b + a)
  233. end)
  234. it("multiply()", function()
  235. local a = vector.new(1, 2, 3)
  236. local b = vector.new(2, 4, 3)
  237. local c = vector.new(2, 8, 9)
  238. local s = 2
  239. local d = vector.new(2, 4, 6)
  240. assert.equal(c, vector.multiply(a, {x = 2, y = 4, z = 3}))
  241. assert.equal(c, vector.multiply(a, b))
  242. assert.equal(d, vector.multiply(a, s))
  243. assert.equal(d, a:multiply(s))
  244. assert.equal(d, a * s)
  245. assert.equal(d, s * a)
  246. assert.equal(-a, -1 * a)
  247. end)
  248. it("divide()", function()
  249. local a = vector.new(1, 2, 3)
  250. local b = vector.new(2, 4, 3)
  251. local c = vector.new(0.5, 0.5, 1)
  252. local s = 2
  253. local d = vector.new(0.5, 1, 1.5)
  254. assert.equal(c, vector.divide(a, {x = 2, y = 4, z = 3}))
  255. assert.equal(c, vector.divide(a, b))
  256. assert.equal(d, vector.divide(a, s))
  257. assert.equal(d, a:divide(s))
  258. assert.equal(d, a / s)
  259. assert.equal(d, 1/s * a)
  260. assert.equal(-a, a / -1)
  261. end)
  262. it("to_string()", function()
  263. local v = vector.new(1, 2, 3.14)
  264. assert.same("(1, 2, 3.14)", vector.to_string(v))
  265. assert.same("(1, 2, 3.14)", v:to_string())
  266. assert.same("(1, 2, 3.14)", tostring(v))
  267. end)
  268. it("from_string()", function()
  269. local v = vector.new(1, 2, 3.14)
  270. assert.is_true(vector.check(vector.from_string("(1, 2, 3.14)")))
  271. assert.same({v, 13}, {vector.from_string("(1, 2, 3.14)")})
  272. assert.same({v, 12}, {vector.from_string("(1,2 ,3.14)")})
  273. assert.same({v, 12}, {vector.from_string("(1,2,3.14,)")})
  274. assert.same({v, 11}, {vector.from_string("(1 2 3.14)")})
  275. assert.same({v, 15}, {vector.from_string("( 1, 2, 3.14 )")})
  276. assert.same({v, 15}, {vector.from_string(" ( 1, 2, 3.14) ")})
  277. assert.same({vector.new(), 8}, {vector.from_string("(0,0,0) ( 1, 2, 3.14) ")})
  278. assert.same({v, 22}, {vector.from_string("(0,0,0) ( 1, 2, 3.14) ", 8)})
  279. assert.same({v, 22}, {vector.from_string("(0,0,0) ( 1, 2, 3.14) ", 9)})
  280. assert.same(nil, vector.from_string("nothing"))
  281. end)
  282. -- This function is needed because of floating point imprecision.
  283. local function almost_equal(a, b)
  284. if type(a) == "number" then
  285. return math.abs(a - b) < 0.00000000001
  286. end
  287. return vector.distance(a, b) < 0.000000000001
  288. end
  289. describe("rotate_around_axis()", function()
  290. it("rotates", function()
  291. assert.True(almost_equal({x = -1, y = 0, z = 0},
  292. vector.rotate_around_axis({x = 1, y = 0, z = 0}, {x = 0, y = 1, z = 0}, math.pi)))
  293. assert.True(almost_equal({x = 0, y = 1, z = 0},
  294. vector.rotate_around_axis({x = 0, y = 0, z = 1}, {x = 1, y = 0, z = 0}, math.pi / 2)))
  295. assert.True(almost_equal({x = 4, y = 1, z = 1},
  296. vector.rotate_around_axis({x = 4, y = 1, z = 1}, {x = 4, y = 1, z = 1}, math.pi / 6)))
  297. end)
  298. it("keeps distance to axis", function()
  299. local rotate1 = {x = 1, y = 3, z = 1}
  300. local axis1 = {x = 1, y = 3, z = 2}
  301. local rotated1 = vector.rotate_around_axis(rotate1, axis1, math.pi / 13)
  302. assert.True(almost_equal(vector.distance(axis1, rotate1), vector.distance(axis1, rotated1)))
  303. local rotate2 = {x = 1, y = 1, z = 3}
  304. local axis2 = {x = 2, y = 6, z = 100}
  305. local rotated2 = vector.rotate_around_axis(rotate2, axis2, math.pi / 23)
  306. assert.True(almost_equal(vector.distance(axis2, rotate2), vector.distance(axis2, rotated2)))
  307. local rotate3 = {x = 1, y = -1, z = 3}
  308. local axis3 = {x = 2, y = 6, z = 100}
  309. local rotated3 = vector.rotate_around_axis(rotate3, axis3, math.pi / 2)
  310. assert.True(almost_equal(vector.distance(axis3, rotate3), vector.distance(axis3, rotated3)))
  311. end)
  312. it("rotates back", function()
  313. local rotate1 = {x = 1, y = 3, z = 1}
  314. local axis1 = {x = 1, y = 3, z = 2}
  315. local rotated1 = vector.rotate_around_axis(rotate1, axis1, math.pi / 13)
  316. rotated1 = vector.rotate_around_axis(rotated1, axis1, -math.pi / 13)
  317. assert.True(almost_equal(rotate1, rotated1))
  318. local rotate2 = {x = 1, y = 1, z = 3}
  319. local axis2 = {x = 2, y = 6, z = 100}
  320. local rotated2 = vector.rotate_around_axis(rotate2, axis2, math.pi / 23)
  321. rotated2 = vector.rotate_around_axis(rotated2, axis2, -math.pi / 23)
  322. assert.True(almost_equal(rotate2, rotated2))
  323. local rotate3 = {x = 1, y = -1, z = 3}
  324. local axis3 = {x = 2, y = 6, z = 100}
  325. local rotated3 = vector.rotate_around_axis(rotate3, axis3, math.pi / 2)
  326. rotated3 = vector.rotate_around_axis(rotated3, axis3, -math.pi / 2)
  327. assert.True(almost_equal(rotate3, rotated3))
  328. end)
  329. it("is right handed", function()
  330. local v_before1 = {x = 0, y = 1, z = -1}
  331. local v_after1 = vector.rotate_around_axis(v_before1, {x = 1, y = 0, z = 0}, math.pi / 4)
  332. assert.True(almost_equal(vector.normalize(vector.cross(v_after1, v_before1)), {x = 1, y = 0, z = 0}))
  333. local v_before2 = {x = 0, y = 3, z = 4}
  334. local v_after2 = vector.rotate_around_axis(v_before2, {x = 1, y = 0, z = 0}, 2 * math.pi / 5)
  335. assert.True(almost_equal(vector.normalize(vector.cross(v_after2, v_before2)), {x = 1, y = 0, z = 0}))
  336. local v_before3 = {x = 1, y = 0, z = -1}
  337. local v_after3 = vector.rotate_around_axis(v_before3, {x = 0, y = 1, z = 0}, math.pi / 4)
  338. assert.True(almost_equal(vector.normalize(vector.cross(v_after3, v_before3)), {x = 0, y = 1, z = 0}))
  339. local v_before4 = {x = 3, y = 0, z = 4}
  340. local v_after4 = vector.rotate_around_axis(v_before4, {x = 0, y = 1, z = 0}, 2 * math.pi / 5)
  341. assert.True(almost_equal(vector.normalize(vector.cross(v_after4, v_before4)), {x = 0, y = 1, z = 0}))
  342. local v_before5 = {x = 1, y = -1, z = 0}
  343. local v_after5 = vector.rotate_around_axis(v_before5, {x = 0, y = 0, z = 1}, math.pi / 4)
  344. assert.True(almost_equal(vector.normalize(vector.cross(v_after5, v_before5)), {x = 0, y = 0, z = 1}))
  345. local v_before6 = {x = 3, y = 4, z = 0}
  346. local v_after6 = vector.rotate_around_axis(v_before6, {x = 0, y = 0, z = 1}, 2 * math.pi / 5)
  347. assert.True(almost_equal(vector.normalize(vector.cross(v_after6, v_before6)), {x = 0, y = 0, z = 1}))
  348. end)
  349. end)
  350. describe("rotate()", function()
  351. it("rotates", function()
  352. assert.True(almost_equal({x = -1, y = 0, z = 0},
  353. vector.rotate({x = 1, y = 0, z = 0}, {x = 0, y = math.pi, z = 0})))
  354. assert.True(almost_equal({x = 0, y = -1, z = 0},
  355. vector.rotate({x = 1, y = 0, z = 0}, {x = 0, y = 0, z = math.pi / 2})))
  356. assert.True(almost_equal({x = 1, y = 0, z = 0},
  357. vector.rotate({x = 1, y = 0, z = 0}, {x = math.pi / 123, y = 0, z = 0})))
  358. end)
  359. it("is counterclockwise", function()
  360. local v_before1 = {x = 0, y = 1, z = -1}
  361. local v_after1 = vector.rotate(v_before1, {x = math.pi / 4, y = 0, z = 0})
  362. assert.True(almost_equal(vector.normalize(vector.cross(v_after1, v_before1)), {x = 1, y = 0, z = 0}))
  363. local v_before2 = {x = 0, y = 3, z = 4}
  364. local v_after2 = vector.rotate(v_before2, {x = 2 * math.pi / 5, y = 0, z = 0})
  365. assert.True(almost_equal(vector.normalize(vector.cross(v_after2, v_before2)), {x = 1, y = 0, z = 0}))
  366. local v_before3 = {x = 1, y = 0, z = -1}
  367. local v_after3 = vector.rotate(v_before3, {x = 0, y = math.pi / 4, z = 0})
  368. assert.True(almost_equal(vector.normalize(vector.cross(v_after3, v_before3)), {x = 0, y = 1, z = 0}))
  369. local v_before4 = {x = 3, y = 0, z = 4}
  370. local v_after4 = vector.rotate(v_before4, {x = 0, y = 2 * math.pi / 5, z = 0})
  371. assert.True(almost_equal(vector.normalize(vector.cross(v_after4, v_before4)), {x = 0, y = 1, z = 0}))
  372. local v_before5 = {x = 1, y = -1, z = 0}
  373. local v_after5 = vector.rotate(v_before5, {x = 0, y = 0, z = math.pi / 4})
  374. assert.True(almost_equal(vector.normalize(vector.cross(v_after5, v_before5)), {x = 0, y = 0, z = 1}))
  375. local v_before6 = {x = 3, y = 4, z = 0}
  376. local v_after6 = vector.rotate(v_before6, {x = 0, y = 0, z = 2 * math.pi / 5})
  377. assert.True(almost_equal(vector.normalize(vector.cross(v_after6, v_before6)), {x = 0, y = 0, z = 1}))
  378. end)
  379. end)
  380. it("dir_to_rotation()", function()
  381. -- Comparing rotations (pitch, yaw, roll) is hard because of certain ambiguities,
  382. -- e.g. (pi, 0, pi) looks exactly the same as (0, pi, 0)
  383. -- So instead we convert the rotation back to vectors and compare these.
  384. local function forward_at_rot(rot)
  385. return vector.rotate(vector.new(0, 0, 1), rot)
  386. end
  387. local function up_at_rot(rot)
  388. return vector.rotate(vector.new(0, 1, 0), rot)
  389. end
  390. local rot1 = vector.dir_to_rotation({x = 1, y = 0, z = 0}, {x = 0, y = 1, z = 0})
  391. assert.True(almost_equal({x = 1, y = 0, z = 0}, forward_at_rot(rot1)))
  392. assert.True(almost_equal({x = 0, y = 1, z = 0}, up_at_rot(rot1)))
  393. local rot2 = vector.dir_to_rotation({x = 1, y = 1, z = 0}, {x = 0, y = 0, z = 1})
  394. assert.True(almost_equal({x = 1/math.sqrt(2), y = 1/math.sqrt(2), z = 0}, forward_at_rot(rot2)))
  395. assert.True(almost_equal({x = 0, y = 0, z = 1}, up_at_rot(rot2)))
  396. for i = 1, 1000 do
  397. local rand_vec = vector.new(math.random(), math.random(), math.random())
  398. if vector.length(rand_vec) ~= 0 then
  399. local rot_1 = vector.dir_to_rotation(rand_vec)
  400. local rot_2 = {
  401. x = math.atan2(rand_vec.y, math.sqrt(rand_vec.z * rand_vec.z + rand_vec.x * rand_vec.x)),
  402. y = -math.atan2(rand_vec.x, rand_vec.z),
  403. z = 0
  404. }
  405. assert.True(almost_equal(rot_1, rot_2))
  406. end
  407. end
  408. end)
  409. it("in_area()", function()
  410. assert.True(vector.in_area(vector.zero(), vector.new(-10, -10, -10), vector.new(10, 10, 10)))
  411. assert.True(vector.in_area(vector.new(-2, 5, -8), vector.new(-10, -10, -10), vector.new(10, 10, 10)))
  412. assert.True(vector.in_area(vector.new(-10, -10, -10), vector.new(-10, -10, -10), vector.new(10, 10, 10)))
  413. assert.False(vector.in_area(vector.new(-10, -10, -10), vector.new(10, 10, 10), vector.new(-11, -10, -10)))
  414. end)
  415. end)