TensorPrincipalInvariants filter

Hi

I am wondering if the expected behavior of the TensorPrincipalInvariants filter is to calculate the eigenvectors as sigma1(vector), sigma2(vector) and sigma3(vector).

If so, I am not able to match the results in my dataset.

These are the tensor definition (I assume in the order XX-YY-ZZ-XY-YZ-XZ)
{E993F715-2486-47BA-90C8-41DC89F7F77F}

And these is calculated sigma1 (vector):
{E7BEFB08-FE28-4F7F-9ABD-473AB459E6EF}

I could not match these values by manual calculation.

Would the plugin by any chance read the tensor in another order?

One more information: it seems that the sign of the sigma’s “Y” variable is inverted in this case… this means that the eigenvalues are ok, but the eigenvectors sometimes go to the wrong quadrant.

Here is how the data is recovered in the filter:

      tensor[0][0] = array->GetComponent(idx, 0); 
      tensor[1][1] = array->GetComponent(idx, 1); 
      tensor[2][2] = array->GetComponent(idx, 2); 
      tensor[0][1] = array->GetComponent(idx, 3); 
      tensor[1][0] = array->GetComponent(idx, 3); 
      tensor[1][2] = array->GetComponent(idx, 4); 
      tensor[2][1] = array->GetComponent(idx, 4); 
      tensor[0][2] = array->GetComponent(idx, 5); 
      tensor[2][0] = array->GetComponent(idx, 5); 

Hence the order is:

XX YY ZZ XY YZ XZ

So looks like your expectation is correct, I do not know why you have different results.

If I understood everything correctly, these are the eigenvectors and eigenvalues.
So, this must be valid:

TENSOR * \sigma_1(vec) = \sigma_1(lambda) * \sigma_1 (vec)

I cannot get this equality withe the values calculated by the filter.
Look at the first eigenvector our of the ultra-simple python code below (the y component should be negative):

TENSOR:
[[ 1.36070e+04 -3.97784e+04 -2.82264e+01]
 [-3.97784e+04 -4.70215e+03  5.65523e+01]
 [-2.82264e+01  5.65523e+01  1.70698e+03]]
EVAL:
 [45270.72363685 -36365.81693694   1706.92330009]
EVEC:
 [[ 7.82391753e-01 -6.22784873e-01  1.46537903e-03] <== here
 [-6.22785208e-01 -7.82392812e-01 -2.71208641e-04]
 [-1.31540666e-03  7.00424981e-04  9.99998890e-01]]

Python:

import numpy as np

mxx = 13607
myy = -4702.15
mzz = 1706.98
mxy = -39778.4
myz = 56.5523
mxz = -28.2264
M = np.array( [[ mxx, mxy, mxz ], [ mxy, myy, myz ] , [ mxz, myz, mzz ]] )
print(f"TENSOR:\n{M}")
eval, evec = np.linalg.eig(M)
print( f"EVAL:\n {eval}" );
print ( f"EVEC:\n {evec}" )

I’m afraid investigation into the filter is needed to figure this out.