[Insight-developers] itkPoint from a math perspective

Luis Ibanez ibanez@cs.unc.edu
Mon, 16 Jul 2001 17:01:12 -0400


Damion Shelton wrote:

> seedPos.Get_vnl_vector().normalize();

an itkPoint is a position in space. 
Normalization is not defined for points.
(it doesn't makes sense to normalize the
components of a position).

In fact, returning a vnl_vector from an
itkPoint is just a backdoor for type missuse.


Normalization is defined for itkVectors
which are the relative position of one
itkPoint with respect to another.
(in this case the normalized vector 
codes for a direction in space).

If normalization is required in a function,
maybe the itkPoint is not the expected parameter.


What is this particular function doing ?



> 
> This is a relatively simple operation - for more complex operations (dot
> products, for instance), I found it neccessary to duplicate Point data in
> order to avoid horribly messy code.

Dot product is not defined over points in space, 
but over vectors, representing the projection of
one vector over the other. 

Could you post the example of what the function is 
intended to compute ?

The typical experience in computer graphics is that 
these types are often used in the wrong sense, just
because all look like n-d arrays.

But their difference are quite important if they
are mapped by a affine transform.


> 
> To summarize: Is there an easy way to interchange 
> Points, CovariantVectors, and vnl_vector's? 

yes:  

itkVector = itkPoint - itkPoint
itkPoint  = itkPoint +/- itkVector

itkPoint + itkPoint = Undefined

itkCovariantVector = itkVector X itkVector (cross product)

scalar = itkVector * itkVector (dot product)

Now, all three, itkPoint, itkVector and itkCovariantVector
have a vnl_vector() method, the only justification for this
conversion is to use any of the vnl methods that requires 
a vnl_vector as an input. This conversion will imply a hit
in performance.

> I'm concerned that having to explicity convert back and
> forth between data types is an impediment to clear code, and possibly a
> speed handicap as well, since these interconversions would occur many
> hundreds of thousands of times in my code.

Agree on the performance side,
but it is important to be careful with the missuse of the types.
an itkPoint is different from an itkVector, and an itkCovariantVector.
They are all different mathematical concepts. The possibility of
converting
them to vnl_vectors was provided only because vnl doesn't make this 
distintion, and use only vnl_vector in the linear algebra sense as 
opposed of the geometric sense. 

In other words, a vnl_vector is like a Nx1 vnl_matrix,
or like an array in Matlab.




Luis