Dual Quaternion
by len_ny
What is this?
DualQuaternion is a module that implements a spherically accurate lerp method for CFrames. Internally, Roblox opted for an NLerp (linear interpolate) method for speed in calculations. However, there is another interpolate method that is spherically accurate that Roblox has yet to provide an open API to, SLerp!
Why use this?
Quaternions
This module includes an improved version of sleitnick/quaternion module with more meta operations including:
- Adding Quaternions
- Multiplication with Numbers
Dual Quaternions
Provides an easy to use, fully functional, and pain free CFrame → Quaternion interface. With support for converting CFrame’s from & to Quaternions, as well as including uncommon methods such as Normalized, and Screw. Best of all, this module was made for Roblox, and it’s developers, by keeping the package-like interface & strict typing to make development as easy as possible.
Example
local startCF, endCF = ...
local startdq, enddq = DualQuaternion.cframe(startCF), DualQuaternion.cframe(endCF)
local parts = { ... }
local a = 0
while true do
for i, part in pairs(parts) do
-- nlerp ❌
part.CFrame = startcf:Lerp(endcf, a)
-- slerp ✔️
part.CFrame = startdq:Lerp(enddq, a):ToCFrame()
end
task.wait()
end