SLERP (Spherical Linear-Interpolate) between two vectors from Python How to do this?

Below is my particular use case and attempt to solve the problem:



Consider Z_axis = (0,0,1) and an arbitrary point also on the unit sphere v.

You can imagine the arc on the surface of the sphere from Z_axis to v.

I wish to create v' by extending the arc by 10%.

How can I do this from Python?

Here is as far as I have got:  

unit_v = v.normalized()
rot_axis = Z_axis.cross(unit_v)


...will give a vector perpendicular to rotation plane, and 

theta = arcsin( abs(rot_axis) ) # &lt;-- some potential problem with positive and negative angles here I think


...will return the angle.

So I was just need to rotate unit_v by theta' = 0.1*theta around rot_axis

How do I do this? 

I can construct a Quaternion Q representing the rotation:

w = cos( theta'/2 )
x,y,z = sin( theta'/2 ) * rot_axis.normalized()

Q = Quaternion(( w,x,y,z ))


and then:

unit_v' = unit_v.rotate(Q)
v' = abs(v) * unit_v'


Is this correct, and is there a cleaner way?

(ref: http://www.essentialmath.com/GDC2013/GDC13_quaternions_final.pdf)
Blender 2.71 (or any recent build) has Vector.slerp (spherical linear interpolation) which accepts values outside 0-1

So you can do:

a = Vector((1, 0, 0))
b = Vector((0, 1, 0))
c = a.slerp(b, 0.5)  # half way


To over rotate 10% do:

c = a.slerp(b, 1.1)




Note, this feature is not included in a stable release yet (but 2.71 will include it).