# rotation copied every second circle

My question is pretty simple.

How to make an object copy rotation of another object with same speed but only every second circle. I know I can animate that using keyframes, but I need to have in constraint.

• Do you mean rotate half as fast, or stop completely every other rotation? Sep 27 '18 at 21:49
• Stop completely every other rotation. Sep 28 '18 at 10:03

You could add a scripted driver to the desired rotation axis of the object with the intermittent rotation, using the following expresion:

var*(int((var/(2.0*pi))%2))


where the variable var, (or whatever you want to call it) refers to the relevant rotation (X,Y,or Z) of the driving object.

Here, the Z rotation of the triangle is being driven by the expression, in which var refers to the the Z rotation of the square.

EDIT in response to your comment:

We can make the expression a little more general by implicitly casting True and False to 1 and 0:

var*(int((var/(2.0*pi))%3)==1)


In this version, the number where the 3 is determines the number of turns in the cycle, and the number where the 1 is says which of the turns to follow, with 0 as the last, counting back. So this example would make the driven object follow the driver on the second of every three turns.

So, in order to have alternating rotations, in the example below, the green triangle uses:

var*(int((var/(2.0*pi))%2)==1)


..and the yellow triangle uses:

var*(int((var/(2.0*pi))%2)==0)


Any more than this - say, "the second and fifth out of every seven".. and it would probably be tidier to write a little function, and add it to the driver_namespace.

• That's what I was looking for. Thank you very much! Sep 29 '18 at 15:02
• @Michal.. I've made an edit to cover this.. Sep 29 '18 at 17:53
• Consider div instead of mod in this case.  var * (var // twopi) Mod is handy for mapping eg mapping on 0, 1 for offset on an orbit div // wil give you the whole number that you are calculating with int-divide-modulus combo Sep 29 '18 at 20:13
• Sorry re confusion, was pointing out that revs or laps can be calculated using div not that mod and int were always avoidable. The ternary operator is another (often more) readable way eg var if 1.0 <= (var // twopi) % 5 <= 2.0 else 0 Ternary op can be nested. Sep 30 '18 at 3:06
• As pointed out often its easier to make a method in the driver namespace to avoid the single line madness. Akin to print pages '[1, 3, 4-6] Would like to see a subexpression in drivers akin to math surface to cut down long expressions.. . Mapping equation to 0 or 1 and driving a copy rotation constraint influence is another way that can be less complex equation wise. Is the square above slightly leading the triangle? 8UV's too man.. envious lol. Sep 30 '18 at 3:06