Z.Mat.anglesFromRotationMatrix freezes app


#1

Issue: Using the Z.Mat.anglesFromRotationMatrix function described here freezes the app. I attached a sample project with the issue. Please check the LookAt script and lines 50 and 51 of the Placement Preview State script, where I try to use the lookAt function. I commented those lines out because they freeze the app.

Affecting: Zapworks Studio

Workaround: None that I’m aware of.

Instant Tracking (1).zpp (324.9 KB)


#2

That’s all pure Javascript so there might be a divide by zero exception or something similar visible in DevTools, perhaps if the thing passed in isn’t actually a rotation matrix. A quick glance at your code looks fine, so might be a bug in the sample code from that forum post or indeed in the anglesFromRotationMatrix code as you say.

Possibly if the two params are identical, as would happen if the intersections weren’t found in a particular frame, then the cross-product ends up as the zero vector, which then is used to define an axis-angle representation. Probably need a special case for 0 rotation in that case.


#3

That’s all pure Javascript so there might be a divide by zero exception or something similar visible in DevTools, perhaps if the thing passed in isn’t actually a rotation matrix

I checked the dev tools. It freezes on the anglesFromRotationMatrix code.


#4

Thanks for the report - you’re right that the function in the Z library throws an exception at the moment.

You can just include the function locally in your project in a script node though - I’ve posted it over on the “look at” thread you referenced:

Note for Instant Tracking you don’t need to jump through these hoops though, see my reply here: