This wiki has been deprecated. You can find updated information from the main VTK website.


From KitwarePublic
< VTK‎ | Tutorials
Jump to navigationJump to search

For both PointData and CellData, you will notice that Scalars and Vectors can be set. VTK uses the physics definitions of these words:

Vectors: A quantity that has magnitude and direction

Scalars: A quantity that has no direction

Something such as a color (RGB 3-tuple) would be called "multi-component data" rather than "vector data", and should not be stored in Vectors.

In VTK, as in physics, the number of components has nothing to do with whether a component is a scalar. The only thing that makes a scalar a "scalar" is that it is unchanged when a geometric transformation is applied to the data.

This distinction is not purely syntactical - VTK treats vectors and scalars differently when performing operations. Let's say that you have vector data stored in a vtkDataSet. Then you rotate the data by passing it through vtkTransformFilter. VTK rotates the Vectors along with the geometry, as you would expect.

Now let's say that you store RGB colors in a vtkDataSet as vectors (instead of as multi-component scalars). If you passed the data through vtkTransformFilter, then each RGB component would be treated as a "direction" and would be rotated. You don't want this to happen, as it doesn't make sense to rotate a color. A geometric transformation should not modify the color data, it should leave it as is. This is what happens with Scalars.