WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Varying rotation speed with spinTo (

mape2k 03-19-2013 11:00 AM

Varying rotation speed with spinTo

I am using the spinTo command in a for loop to spin to different view angles during an experiment. I want the rotation speed to be constant, independent from the actual and desired view angle.
However, the spinTo command gives me different rotation speeds when I use it. Sometimes its faster, and sometimes its slower, even though I specify a constant speed angle.

I have attached a working minimum example. Here, the speed will vary, seemingly at random.


import viztask
import viz
import vizact

angles = [-120,150,100,150,-170,50,90,150]


def run():
        for k in angles:
                print str(k)
                yield viztask.waitKeyDown(' ')
                yield viztask.addAction(view, vizact.spinTo(euler=[k,0,0],speed=80,interpolate = vizact.linear))


Thank you for your help in advance!

farshizzo 03-20-2013 08:23 AM

This appears to be a bug with how the rotational differences are computed. It doesn't seem to be using the shortest distance in all cases. This will be fixed in the next release. In the meantime you can add the following code to the beginning of your script to get the correct behavior:

import math
import vizmat
def QuatDiff(q1,q2):
        w = abs((vizmat.Quat(q1) * vizmat.Quat(q2).inverse()).w)
        return viz.degrees(math.acos(w) * 2.0)
vizmat.QuatDiff = QuatDiff

mape2k 03-22-2013 07:48 AM

Thank you for your quick reply and the hot-fix!

All times are GMT -7. The time now is 02:01 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC