include/vector.h
branchpyrit
changeset 83 e3a2a5b26abb
parent 78 9569e9f35374
child 84 6f7fe14782c2
equal deleted inserted replaced
82:930a2d3ecaed 83:e3a2a5b26abb
    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()); };