title: Designing a Vector3D class
body: <p>I dont know which is the best practice when we want to create a new vector 3D class, i mean, which of this two examples is the best way ?</p>
  
  <pre><code>class Vec3D
  {
     private:
  
           float m_fX;
           float m_fY;
           float m_fZ;
  
  ...
  };
  </code></pre>
  
  <p>or</p>
  
  <pre><code>class Vec3D
  {
     private:
  
           float m_vVec[3];
  ...
  };
  </code></pre>
  
  <p>With the first aproach, we have individual variables, we canot be sure to be contiguous in memory, so caches can fail, but access to this variables are a single instruction.</p>
  
  <p>With the second aproach, we have a vector of 3 contiguous floats in memory, caches are fine here, but every access will make an extra sum of variable offset. Buti think that this vector aproach could fit better with optimitzations like SSE2/3 or something.</p>
  
  <p>Which aproach is better, i'm lost, i need advices :)</p>
  
  <p>Thanks for your time :)</p>
  
  <p>LLORENS</p>