[vtkusers] how to change coordinate system from right to left-handed

Sean McInerney seanm at nmr.mgh.harvard.edu
Wed Mar 24 14:56:38 EST 2004


Hi David,

   Just in case you need to swap axes in addition to mirroring (which 
negative scaling does accomplish, of course), you could construct a 
permutation matrix for your vtkTransform. e.g.

  1  0  0  0    This is just a simple negative scaling that
  0 -1  0  0    mirrors the y-axis ... like SetScale(1,-1,1).
  0  0  1  0
  0  0  0  1

  1  0  0  0    While this mirrors the y-axis and swaps it
  0  0 -1  0    with the z-axis.
  0  1  0  0
  0  0  0  1

More generally, what this does is change the direction cosines of the 
three principal axes ... direction cosines being the cosines of the 
angles between a unit vector and the given axis.

xx xy xz  0    x-axis direction cosines
yx yy yz  0    y-axis direction cosines
zx zy zz  0    z-axis direction cosines
  0  0  0  1

For extra fun, the 4th column corresponds to translation and can be used 
to recenter you data as well.

-Sean

P.S. This answer SEEMED simple before writing it out!

> Date: Tue, 23 Mar 2004 14:35:57 +0100
> From: Vetsch David <vetsch at vaw.baug.ethz.ch>
> Reply-To: vetsch at vaw.baug.ethz.ch
> Organization: VAW ETHZ
> To: vtkusers at vtk.org
> Subject: [vtkusers] how to change coordinate system from right to
> left-handed
> 
> Hi,
> I got RectilinearGrid data from a CFD solver with a left-handed
> coordinate system. I tried out a lot of things in VTK but didn't manage
> to change the data or the basic coordinate system to a right-handed one
> (it needs mirroring). Does anybody know how to do that (..in a simple
> way)?
> 
> --
>  David Vetsch
>  Applied Numerics Division
>  Laboratory of Hydraulics, Hydrology and Glaciology
>  ETH-Zentrum
>  CH-8092 Zurich
>  Switzerland
> 
>  phone:    +41 1 632 41 04
>  fax:      +41 1 632 11 92
>  email:    vetsch at vaw.baug.ethz.ch



More information about the vtkusers mailing list