1
$\begingroup$

I'm currently putting together a variation of Zack Hixson's tile flip. Instead of a grid of objects created within animation nodes, I've used an predetermined Group based on an array. (I tried the grid approach first but got stuck with the same problem).

What i'm trying to do is make tiles remain flipped over once the empty has passed, rather than flipping back to their original position. I've tried all sorts of ways to effect this, the latest using nested loops: enter image description here

What i've tried to do is test the rotation of each object in the group and, if it's x rotation is 180 degrees, it should be skipped and the next object in the loop should be tested. Interestingly, as seen in the viewer, the rotation comes up at 180.00001 degrees despite only being set at 180 as the empty passes. Inevitably the test fails. enter image description here

Any thoughts on where i'm going wrong? As i say, i've put the test inside the core transformation loop in various forms but the it's comprehensively ignored in every location!!

Thanks in advance.

$\endgroup$

1 Answer 1

4
$\begingroup$

I think that the main problem is that you are comparing the Angles using an Equal To compare node, generally you shouldn't use Equal to when comparing floats. Instead, for instance, if you want to check that a float x is equal to a float y, you check if |x-y|< epsilon where epsilon is some small float like 0.001.

So a node tree like this:

Node Tree

Would result in:

Result

Tip: Try not to use degrees, use radians.

$\endgroup$
2
  • $\begingroup$ Omar, that's brilliant and rich with ideas. I really appreciate your time and the guidance you've given. It'll be radians for me from now on!! Thank you. Stephen $\endgroup$ Oct 23, 2017 at 14:48
  • $\begingroup$ You are right, the reason to this is python is only a programming language, it approximates math, because they are only 53 bits allocated for python Floating Points. $\endgroup$ Oct 23, 2017 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .