[vtkusers] Rows versus columns bug in vtkTensorGlyph?
Ashok Kumar
ashok at nmr.mgh.harvard.edu
Fri May 9 16:29:23 EDT 2003
As given in the the VTK File Formats section of the User guide, 3x3 tensors
are entered as:
T00 T01 T02
T10 T11 T12
T20 T21 T22
But in the piece of code quoted below from vtkTensorGlyph.cxx, the rows of
above matrix are being called columns. The "m" matrix below is actually the
transpose of the tensor being read. Also the code following "//use tensor
columns as eigenvectors" is actually using the "rows" of the tensor data.
This doesn't cause problems if one is inputing symmetric tensors (as most
physical 3x3 tensors of interest are symmetrical). But with the option
ExtractEigenvaluesOff, I started getting sheared looking cuboids when I
actually gave the eigenvectors scaled by eigenvalues as the "columns" of the
tensor. But when I gave them as "rows" the problem vanished.
Another point: When ExtractEigenvalues is set On, then it makes sense to
call the input data as the "tensor". But when "ExtractEigenvalues" is
turned "off", then the input matrix consisting of eigenvectors scaled by
their eigenvalues arranged in columns, is not a tensor anymore. It is
actually the Determinant of the tensor multiplied by the similarity
transformation (det(T)*S) required for diagonalization (I=STS^). So may be
a different term than "tensor" will be more appropriate in that respect.
May be the input should just be called a "matrix", which could be the actual
tensor in one case and the matrix of eigenvectors multiplied by their
eigenvalues in the second case (with ExtractEigenvaluesOff).
----------------------------------------------------------------------------
-----
from vtkTensorGlyph.cxx
213: tensor = inTensors->GetTuple(inPtId);
214:
215: // compute orientation vectors and scale factors from tensor
216: if ( this->ExtractEigenvalues ) // extract appropriate
eigenfunctions
217: {
218: for (j=0; j<3; j++)
219: {
220: for (i=0; i<3; i++)
221: {
222: m[i][j] = tensor[i+3*j];
223: }
224: }
225: vtkMath::Jacobi(m, w, v);
226:
227: //copy eigenvectors
228: xv[0] = v[0][0]; xv[1] = v[1][0]; xv[2] = v[2][0];
229: yv[0] = v[0][1]; yv[1] = v[1][1]; yv[2] = v[2][1];
230: zv[0] = v[0][2]; zv[1] = v[1][2]; zv[2] = v[2][2];
231: }
232: else //use tensor columns as eigenvectors
233: {
234: for (i=0; i<3; i++)
235: {
236: xv[i] = tensor[i];
237: yv[i] = tensor[i+3];
238: zv[i] = tensor[i+6];
239: }
More information about the vtkusers
mailing list