Hi Renato, perhaps I can quickly help out here, negateIt() and
scaleIt() are functions of the MQuaternion class, which you can find
documented in the Maya API:

http://download.autodesk.com/global/docs/mayasdk2012/en_us/index.html

Cheers!

  -André



On Oct 5, 3:44 am, Renato Polimeno <[email protected]> wrote:
> Hey Chad, that is a beatifull peace of code!
>
> Could you please tell me what are those functions <value>.negateIt() and
> <value>.scaleIt() ?
> Properties of python numbers I guess ?! Could you point me a doc link ?
>
> Again, thanks for sharing !
>
>
>
>
>
>
>
>
>
> On Tue, Oct 4, 2011 at 6:50 PM, Chad Vernon <[email protected]> wrote:
> > You could implement slerp function:
>
> > import math
> > def quaternionSlerp(a, b, t):
> >     cos = quaternionDot(a, b)
> >     if cos < 0.0:
> >         cos = quaternionDot(a, b.negateIt())
> >     theta = math.acos(cos)
> >     sin = math.sin(theta)
>
> >     if sin > 0.001:
> >         w1 = math.sin((1.0 - t) * theta) / sin
> >         w2 = math.sin(t * theta) / sin
> >     else:
> >         w1 = 1.0 - t
> >         w2 = t
> >     aa = OpenMaya.MQuaternion(a)
> >     bb = OpenMaya.MQuaternion(b)
> >     aa.scaleIt(w1)
> >     bb.scaleIt(w2)
>
> >     return aa + bb
>
> > def quaternionDot(q1, q2):
> >     return (q1.x * q2.x) + (q1.y * q2.y) + (q1.z * q2.z) + (q1.w * q2.w)
>
> > On Tue, Oct 4, 2011 at 2:47 PM, David Moulder 
> > <[email protected]>wrote:
>
> >> I don't know if slerp is correctly exposed but I can tell you that there
> >> is a new api binding available in 2012.  Maya API 2.  Its a faster and more
> >> friendly python api and the docs suggest that slerp is exposed correctly.
>
> >> On Tue, Oct 4, 2011 at 5:26 PM, a_adam <[email protected]> wrote:
>
> >>> Hi there,
>
> >>> just joined in here, and I'm looking forward to some good discussions!
> >>> And of course I stumbled into a problem today which brought me here in
> >>> the first place: I can't for the life of me trigger the slerp function
> >>> from the MQuaternion class.
>
> >>> The API docs tell me that there are two slerps (odd enough), one
> >>> considering spin and being marked as not exposed to scripting, and a
> >>> simple one without a spin argument which should be accessable to
> >>> scripting. It is this simpler version which I'm trying to get to work.
>
> >>> I've seen in this group's archive that slerp indeed does not seem to
> >>> be not implemented in the Python wrapper. However, that post is over a
> >>> year old, and I asked myself if Autodesk did anything for Maya 2012 to
> >>> make this work? Or anyone found a workaround in the meantime?
>
> >>> Many thanks in advance for a quick hint, cheers!
>
> >>> -Andre
>
> >>> --
> >>> view archives:http://groups.google.com/group/python_inside_maya
> >>> change your subscription settings:
> >>>http://groups.google.com/group/python_inside_maya/subscribe
>
> >> --
> >> David Moulder
> >>http://www.google.com/profiles/squish3d
>
> >>  --
> >> view archives:http://groups.google.com/group/python_inside_maya
> >> change your subscription settings:
> >>http://groups.google.com/group/python_inside_maya/subscribe
>
> >  --
> > view archives:http://groups.google.com/group/python_inside_maya
> > change your subscription settings:
> >http://groups.google.com/group/python_inside_maya/subscribe
>
> --
> ______________________________
>
> -> Renato Polimeno
> +55 11 7539 3615
> renatopolimeno.com <http://www.renatopolimeno.com>
>  <http://www.renatopolimeno.com/>facebook.com/renato.polimeno<http://www.facebook.com/renato.polimeno>
> @renatopolimeno <http://www.twitter.com/renatopolimeno>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to