Did I interpret this wiki article on spherical interpolation correctly?

42 Views Asked by At

In Lua pseudocode, I believe the wikipedia article here is saying that the formula is used in the following way:

-- assume a and b are unit vectors
local a = Vector3.new( ... );
local b = Vector3.new( ... );

function slerp( a, b, t )
    local omega = Math.acos( a:Dot( b ) );
    local sinOmega = Math.sin( omega );
    return ( Math.sin( ( 1 - t ) * omega ) / sinOmega ) * a + ( Math.sin( omega * t ) / sinOmega ) * b 
end

slerp( a, b, .5 ); -- returns a vector that represents a point on the sphere interpolated halfway between a and b.