mirror of
https://github.com/appgurueu/modlib.git
synced 2024-12-23 05:42:28 +01:00
Add vector.angle
This commit is contained in:
parent
0d1c5596a6
commit
f0f48c0fb4
@ -175,6 +175,13 @@ function dot(v, other_v)
|
||||
return sum
|
||||
end
|
||||
|
||||
--+ Angle between two vectors
|
||||
--> Signed angle in radians
|
||||
function angle(v, other_v)
|
||||
-- Based on dot(v, w) = |v| * |w| * cos(x)
|
||||
return math.acos(dot(v, other_v) / length(v) / length(other_v))
|
||||
end
|
||||
|
||||
function box_box_collision(diff, box, other_box)
|
||||
for index, diff in pairs(diff) do
|
||||
if box[index] + diff > other_box[index + 3] or other_box[index] > box[index + 3] + diff then
|
||||
|
Loading…
Reference in New Issue
Block a user