For a mesh slicing algorithm, I need to move (and rotate) the vertices of a mesh.
For this I convert each vertex into a 4x4matrix, and then cross product this with my rotation and translation matrix (the slice position and orientation).
All works 100%, but converting the 3 values into an identity matrix +3 values takes 95% of the computation time.... crazy !
I have tried various options, but I am sure there is a faster way.
Any suggestions to make this 4x4 matrix from 3 values faster? (alternatively "A x B" which can accept data with a position vector)
Since I have 10000 vertices (or more), it takes 4-5 seconds for this operation alone, which is clearly unacceptable for real time use.
Solved! Go to Solution.
First, in general, when performance is required, Formula nodes should be avoided. They are slower than LabVIEW primitives and basic functions.
Second, in general, you do not need to convert a (x,y,z) vector into a 4x4 matrix. You only need to add a a 1 at the end (x,y,z,1). This is the reason why the 4x4 matrix for rotation-translation was invented in the first place. You can use LabVIEW matrix VIs with a matrix and a vector.
Third, use For loops with Parallelism enabled. Make sure that all the VIs within the loop are reentrant. You might be able to improve performance by making heavy matrix operations by calling a dll compiled in C++. By playing with those parameters, you should be able to get a significant performance improvement.
In any case, you should not expect to get near the same level of performance than what you get with the rotation of objects within 3D picture controls or most other 3D applications. Those use the graphic cards to manipulate the objects. The vertex rotations are one of the operations that the graphic cards are designed for. They are massively parallel.
Changed the code to just add the 1 to the position vector.....
the 95% is now closer to 1% of the processing time.
Thanks Marc, I am back to real-time.