[Insight-developers] itkPoint from a math perspective

Luis Ibanez ibanez@choroid.cs.unc.edu
Tue, 17 Jul 2001 17:47:04 -0400 (EDT)


On Tue, 17 Jul 2001, Damion Shelton wrote:
>
> I suppose that since the * Vector method implies the scalar/dot
> product, I
> could also say:
>
> ( pointA.GetVectorFromOrigin() )*( pointB.GetVectorFromOrigin() )


  Yes, that's the way to do it more efficiently, if you don't
  expect to use the vectors for anything else...

>
> Perhaps, but often times the point/vector distinction is implied by the way
> the data type is used rather than explicitly in the data type.
>
> Another example would be averaging the position of two points, as in PointC
> = (PointA + PointB) / 2
>

 Your right, this is one of these commonly needed operations.

 Addition of points that's well defined is the barycentric sum:

   ResultPoint =  Sum( coefficient(i) * Point(i) )

 given that   Sum( coefficient(i) )  = 1

 This is very useful in interpolation. It is implicitly done in bezier
 curves for example.

 I agree in the inconvinience of doing three function calls for a
 simple operation. One option is to add a method like:

 itkPoint MedianPoint(const itkPoint &a, const itkPoint &b);

 or more generaly interpolating with a fraction alpha in [0,1]
 like:

 itkPoint Interpolate(itkPoint,itkPoint,alpha);


 additionaly, if it happens that taking the scalar product of
 two vectors corresponding to positions of points from the origin is
 a commonly needed operation, the simplest way to get around is to
 add a method to the itkPoint class doing specifically this.

 for example, for computing the euclidean distance between two
 points, you are not forced to compute the vector between
 them and take the norm, there is a specific method:

       EuclideanDistanceTo( itkPoint );

 so for operations that are well defined, probably the best way to go
 is to create the particular operation as a method in the point
 class, and release users from the inconvinience of doing multiple
 inefficient calls with primitive objects.

>
> This operation is defined when the point/vector distinction isn't present.
> When the distinction is made, the operation has to be expressed as:
>
> PointC = PointA + (PointB-PointA) / 2
>
> I'm not saying that this is terribly inconvenient or anything, nor am I
> neccessarily suggesting changing anything about the Point/Vector
> distinction. But, it might be worthwhile to spend extra time in the beta
> documentation talking about how these types are meant to be used.
>


 Well, the true is that it IS inconvenient, for cases like this we
 should add specific efficient methods for operations that are commonly
 needed between points, vectors and so on. It is a matter of identifing
 them correctly.

 There are also more complex operations like getting a Principal
 Components analysis of a set of points. This higer level actions
 will probably be better implemented as Calculator classes that
 receive a Point container (eg std::vector<Points>) and then compute
 internally.



 I also agree that  Documentation is key, and seems that we will
 have to write the double in doc than in code, in order to insure
 that the toolkit is widely used.



  Luis