equal
deleted
inserted
replaced
69 z *= f; |
69 z *= f; |
70 return *this; |
70 return *this; |
71 }; |
71 }; |
72 |
72 |
73 // get normalized copy |
73 // get normalized copy |
74 Vector3 unit() const |
74 friend Vector3 normalize(Vector3 &v) |
75 { |
75 { |
76 Vector3 u(*this); |
76 const Float f = 1.0f / v.mag(); |
77 return u.normalize(); |
77 return v * f; |
78 }; |
78 }; |
79 |
79 |
80 // square magnitude, magnitude |
80 // square magnitude, magnitude |
81 Float mag2() const { return x * x + y * y + z * z; }; |
81 Float mag2() const { return x * x + y * y + z * z; }; |
82 Float mag() const { return sqrtf(mag2()); }; |
82 Float mag() const { return sqrtf(mag2()); }; |