- added a Sum function to TVector familiy

Duke uses this kind of distance check quite a lot so it makes sense to add it to the vectors.
This commit is contained in:
Christoph Oelckers 2022-09-13 00:46:38 +02:00
parent 1d7f2c81b6
commit 3352783be2
3 changed files with 24 additions and 6 deletions

View file

@ -237,6 +237,12 @@ struct TVector2
{
return X*X + Y*Y;
}
double Sum() const
{
return abs(X) + abs(Y);
}
// Return a unit vector facing the same direction as this one
TVector2 Unit() const
@ -601,6 +607,12 @@ struct TVector3
{
return X*X + Y*Y + Z*Z;
}
double Sum() const
{
return abs(X) + abs(Y) + abs(Z);
}
// Return a unit vector facing the same direction as this one
TVector3 Unit() const
@ -900,6 +912,12 @@ struct TVector4
{
return X*X + Y*Y + Z*Z + W*W;
}
double Sum() const
{
return abs(X) + abs(Y) + abs(Z) + abs(W);
}
// Return a unit vector facing the same direction as this one
TVector4 Unit() const