# Quaternions and collisions

I’m a new ETC student using Panda in a round 1 world, and I discovered a potential issue with quaternions and collisions.

If do this on an object that has a CollisionNode on it, there’s a chance that collisions will stop working entirely:

``````prevRot = LRotationf(self.spatula.getQuat())
self.spatula.setQuat(prevRot * LRotationf(Vec3(0, 1, 0.766), change))``````

However, if I do it this way, collisions will remain working:

``````
self.spatula.setR(self.spatula.getR() + change)``````

Well, there’s nothing directly related between the collision system and the use of quaternions. The collision system neither knows nor cares whether you set an object’s rotation using the HPR angles or via a quaternion, so whatever the cause-and-effect relation is here, it must be pretty subtle.

One possibility is that there is some bug in the quaternion code, as yet undetected, that causes your transform matrix to become singular (for instance, by introducing a scale to zero, or a non-uniform scale that squashes it flat in one plane). A singular transform matrix like this would interfere with the collision calculation.

If this is the case, you could help us by examining your node’s transform matrix when the collisions stop working, for instance by:

``````
print self.spatula.getNetTransform()``````

If you observe a scale to zero in one or more axes, or some other kind of invalid transform, that will explain why the collisions have stopped working. If you do observe this scale and you didn’t put it there, you can also do this to show which node it came from, in case it got inherited from a parent node:

``````
self.spatula.reverseLs()``````

David