[vtkusers] Vector projection

David Doria daviddoria+vtk at gmail.com
Fri Sep 11 22:22:10 EDT 2009


I didn't see anything like this in vtkMath, does it exist somewhere else? Or
can this be added somewhere?


void Project(const double* A, const double* B, double* Projection)
{
    //find the projection of A on B
    double scale = vtkMath::Dot(A,B)/pow(vtkMath::Norm(B), 2);
    for(unsigned int i = 0; i < 3; i++)
        Projection[i] = scale * B[i];

}

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090911/f69ecff2/attachment.htm>


More information about the vtkusers mailing list