[vtkusers] why use SetScalars instead of SetVectors for coloring

David Gobbi david.gobbi at gmail.com
Thu Jan 12 10:53:00 EST 2012


On Thu, Jan 12, 2012 at 8:27 AM, David Doria <daviddoria at gmail.com> wrote:
> On Sun, Oct 16, 2011 at 1:37 PM, Yifei Li <yifli82 at gmail.com> wrote:
>> Hi,
>>
>> I saw examples using SetScalars(colors) to color cells/points, where
>> 'colors' is a vtkUnsignedCharArray with 3 components in each tuple.
>>
>> A (r, g, b) color can be considered as a vector, I don't understand why vtk
>> treast color as scalar data instead of vector data. Why can't I use
>> SetVectors?
>>
>> Can someone please  explain the reason?
>>
>> Thanks
>>
>> Yifei
>
> I think the idea is that VTK treats "vectors" only as "things that
> indicate a direction", rather than "something with multiple elements".
> For example, normals to a surface (normal vectors) are "vectors", the
> gradient of an image would be "vectors", but colors, though they have
> 3 components, do not represent a direction so they are "scalars".
>
> David

That is correct.  Where vtkDataSets are concerned, vector data is data
that has magnitude and direction, using the physics definition of
vector rather than the much looser definition that is encountered in
computer science and linear algebra.  In VTK, color data would be
called multi-component data rather than vector data, and each RGB
triplet would be a tuple rather than a vector.

In VTK all vector data is multi-component data, but not all
multi-component data is vector data.

Unfortunately the new vtkVector class that was recently added to VTK
has muddied the definition, and in retrospect it probably should have
been named vtkTuple.

 - David



More information about the vtkusers mailing list