mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 01:03:46 +01:00
Fix vector.rotate3
This commit is contained in:
parent
bcda0511b1
commit
228bfda006
@ -190,10 +190,13 @@ function angle(v, w)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Uses Rodrigues' rotation formula
|
-- Uses Rodrigues' rotation formula
|
||||||
|
-- axis must be normalized
|
||||||
function rotate3(v, axis, angle)
|
function rotate3(v, axis, angle)
|
||||||
|
assert(#v == 3 and #axis == 3)
|
||||||
local cos = math.cos(angle)
|
local cos = math.cos(angle)
|
||||||
return multiply_scalar(v, cos)
|
return multiply_scalar(v, cos)
|
||||||
+ multiply_scalar(cross3(axis, v), math.sin(angle))
|
-- Minetest's coordinate system is *left-handed*, so `v` and `axis` must be swapped here
|
||||||
|
+ multiply_scalar(cross3(v, axis), math.sin(angle))
|
||||||
+ multiply_scalar(axis, dot(axis, v) * (1 - cos))
|
+ multiply_scalar(axis, dot(axis, v) * (1 - cos))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user