Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1.     inline double magnitudeSquared () const
  2.     {
  3.         return X * X + Y * Y + Z * Z;
  4.     }
  5.  
  6.     inline  double magnitude () const
  7.     {
  8.         return sqrt(magnitudeSquared());
  9.     }
  10.  
  11.     inline  void normalize (double mag = 1.0)
  12.     {
  13.         const double by = mag / magnitude();
  14.  
  15.         X *= by;
  16.         Y *= by;
  17.         Z *= by;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement