Nuke has its own python math module (nuke.math) that provides support for Matrix, Vector, and Quaternion classes, and useful functions to operate with them. If you need to do any maths involving vector operations in Nuke (like adding or substracting vectors, transforming vectors with transformation matrices, calculating vector reflections, inverse-projecting a 3d vector into 2d screen coordinates, etc), then the nuke.math module can be of great help.
Unfortunately, at this time there is no way to write out pixel data using python in Nuke, so the use of this module will be rather limited. However, it can still prove very useful to do any kind of vector and matrix operations between knobs, 3d objects, and even on sampled pixels (just not writing them out, unfortunately)
The documentation is a bit scarce on the nuke.math module at the moment, and the little there is is mostly a direct port from the same classes in C++. When first facing this module, I found myself having to learn how to use it the hard way, so here's some notes, examples, tips and extended documentation on the nuke.math module, hoping it will make it a bit more accessible to anyone trying to use it for the first time.
Note: Part of the descriptions of some classes and methods is taken from the C++ Plugin development documentation, but I've tried to expand a little more to give a better insight on what the different methods can be used for.
- Next >>