# 3D Vision

This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.
Highlighted
Solved! Go to solution

## Mesh rotation and slicing - A x B optimisations

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.

Message 1 of 3
(1,832 Views)
2 REPLIES
Solution
Accepted by topic author Philippe_RSA
07-17-2017 05:13 AM

## Re: Mesh rotation and slicing - A x B optimisations

Hi Philippe_RSA,

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.

Good luck

Marc Dubois
HaroTek LLC
www.harotek.com

Message 2 of 3
(1,820 Views)

## Re: Mesh rotation and slicing - A x B optimisations

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.

Message 3 of 3
(1,812 Views)
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.