Artifact 80f52c4aaf8062a76d2eb78857dfcacc1095b75caa2302da194ff65978e9ce0f:
- File lib/math.lua — part of check-in [147592b8e9] at 2020-10-26 03:58:08 on branch trunk — add over-time spellcasting abstraction to enable metamagic and in particular disjunction, add more animations and sound effects, add excavation spell, possibly some others, forget when the last commit was, edit a bunch of magitech to make it subject to the disjunction mechanism (throw up a disjunction aura and waltz right through those force fields bby, wheee), also illumination spells, tweak runeforge and rune frequence to better the balance and also limit player frustration, move some math functions into their own library category, various tweaks and bugfixes, probably other shit i don't remember (user: lexi, size: 583) [annotate] [blame] [check-ins using]
local fn = {} fn.vsep = function(vec) -- separate a vector into a direction + magnitude local magnitude = math.max(math.abs(vec.x), math.abs(vec.y), math.abs(vec.z)) local inv = 1 / magnitude return vector.multiply(vec,inv), magnitude end fn.vdcomp = function(dist,v1,v2) -- compare the distance between two points -- (cheaper than calculating distance outright) local d if v2 then d = vector.subtract(v1,v2) else d = v1 end local dsq = (d.x ^ 2) + (d.y ^ 2) + (d.z ^ 2) return dsq / (dist^2) -- [0,1) == less then -- 1 == equal -- >1 == greater than end return fn