This commit is contained in:
Christoph Oelckers 2016-10-03 16:22:16 +02:00
commit 15af9242d6

View file

@ -556,18 +556,30 @@ struct TVector3
// Resizes this vector to be the specified length (if it is not 0)
TVector3 &MakeResize(double len)
{
double scale = len / Length();
double vlen = Length();
if (vlen != 0.)
{
double scale = len / vlen;
X = vec_t(X * scale);
Y = vec_t(Y * scale);
Z = vec_t(Z * scale);
}
return *this;
}
TVector3 Resized(double len)
{
double scale = len / Length();
double vlen = Length();
if (vlen != 0.)
{
double scale = len / vlen;
return{ vec_t(X * scale), vec_t(Y * scale), vec_t(Z * scale) };
}
else
{
return *this;
}
}
// Dot product
double operator | (const TVector3 &other) const