title: 3D vector rotation in C++
body: <p>I have tried to implement the rotation of a 3D vector around an arbitrary axis for an arbitrary angle, using Rodrigues' rotation formula (<a href="https://en.wikipedia.org/wiki/Rodrigues&#39;_rotation_formula" rel="nofollow noreferrer">Rodrigues' rotation formula)</a>:</p>
  
  <pre><code>vector3 vector3::rotate(const vector3 &amp;axis, double theta) const
  {
      double cos_theta = cos(theta);
      double sin_theta = sin(theta);
      vector3 rotated = *this*cos_theta + (axis^*this)*sin_theta + axis*(axis*(*this))*(1 - cos_theta);
      return rotated;
  }
  </code></pre>
  
  <p>but it doesn't seem to be working correctly. I don't know what I am missing here, any help would be appreciated.</p>
  
  <p><em>Edit</em>: </p>
  
  <p>These are the operators I used:</p>
  
  <pre><code>vector3 operator*(double) const; //multiplication by scalar
  friend vector3 operator*(double, const vector3&amp;); //multiplication by scalar
  double operator*(const vector3&amp;) const; //dot product
  vector3 operator^(const vector3&amp;) const; //cross product
  </code></pre>
  
  <p>and they have been tested (they work correctly).</p>