<font size="2"><font face="verdana,sans-serif">I just took a look at vtk 5.6.1, and the Norm function looks like this:<br></font></font><div><font class="Apple-style-span" face="verdana, sans-serif"><div>  // Description:</div>

<div>  // Compute the norm of 3-vector.</div><div>  static float Norm(const float x[3]) {</div><div>    return static_cast&lt;float&gt; (sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ) );};</div><div><br></div><div>That means it returns the magnitude of the vector, and the Normalize method works as it should:</div>

<div>1. calculate magnitude</div><div>2. if it is not zero</div><div>  3. divide all vector components by the magnitude</div><div>4. return magnitude</div><div><br></div><div>Nothing can be erased here, only made more clear, like this:</div>

<div><br></div><div><div>inline double vtkMath::Normalize(double x[3])</div><div>{</div><div> double den = vtkMath::Norm( x );</div><div> if ( den  != 0.0 )</div><div>   {</div><div>   for (int i=0; i &lt; 3; i++)</div><div>

     {</div><div>     x[i] /= den;</div><div>     }</div><div>   }</div><div> return den;</div><div>}</div></div><div><br></div><div><br></div></font><div class="gmail_quote">On Mon, Aug 15, 2011 at 08:58, al.gry <span dir="ltr">&lt;<a href="mailto:al.gry@web.de">al.gry@web.de</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi everyone,<br>
<br>
I posted this thread last week but it wasn&#39;t accepted so Im trying again.<br>
<br>
I just looked into vtkMath source code provided via VTK.git and I found<br>
things like this:<br>
<br>
inline double vtkMath::Normalize(double x[3])<br>
{<br>
  double den;<br>
  if ( ( den = vtkMath::Norm( x ) ) != 0.0 )<br>
    {<br>
    for (int i=0; i &lt; 3; i++)<br>
      {<br>
      x[i] /= den;<br>
      }<br>
    }<br>
  return den;<br>
}<br>
<br>
I guess the for-loop can be erased since it&#39;s useless... btw, if-instruction<br>
doesn&#39;t do anything so it&#39;s also useless.<br>
<br>
Regards, Al<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Useless-comupations-in-vtkMath-tp4700083p4700083.html" target="_blank">http://vtk.1045678.n5.nabble.com/Useless-comupations-in-vtkMath-tp4700083p4700083.html</a><br>


Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div>