Base: fix bugprone reserved identifier

This commit is contained in:
wmayer
2023-11-20 17:27:38 +01:00
committed by wwmayer
parent 959a9e1ea4
commit 85e536394d
3 changed files with 200 additions and 200 deletions

View File

@@ -32,15 +32,15 @@
using namespace Base;
template<class _Precision>
Vector3<_Precision>::Vector3(_Precision fx, _Precision fy, _Precision fz)
template<class float_type>
Vector3<float_type>::Vector3(float_type fx, float_type fy, float_type fz)
: x(fx)
, y(fy)
, z(fz)
{}
template<class _Precision>
_Precision& Vector3<_Precision>::operator[](unsigned short usIndex)
template<class float_type>
float_type& Vector3<float_type>::operator[](unsigned short usIndex)
{
switch (usIndex) {
case 0:
@@ -53,8 +53,8 @@ _Precision& Vector3<_Precision>::operator[](unsigned short usIndex)
return x;
}
template<class _Precision>
const _Precision& Vector3<_Precision>::operator[](unsigned short usIndex) const
template<class float_type>
const float_type& Vector3<float_type>::operator[](unsigned short usIndex) const
{
switch (usIndex) {
case 0:
@@ -67,44 +67,44 @@ const _Precision& Vector3<_Precision>::operator[](unsigned short usIndex) const
return x;
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::operator+(const Vector3<_Precision>& rcVct) const
template<class float_type>
Vector3<float_type> Vector3<float_type>::operator+(const Vector3<float_type>& rcVct) const
{
Vector3<_Precision> cVctRes;
Vector3<float_type> cVctRes;
cVctRes.x = x + rcVct.x;
cVctRes.y = y + rcVct.y;
cVctRes.z = z + rcVct.z;
return cVctRes;
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::operator&(const Vector3<_Precision>& rcVct) const
template<class float_type>
Vector3<float_type> Vector3<float_type>::operator&(const Vector3<float_type>& rcVct) const
{
Vector3<_Precision> cVctRes;
cVctRes.x = x * (_Precision)fabs(rcVct.x);
cVctRes.y = y * (_Precision)fabs(rcVct.y);
cVctRes.z = z * (_Precision)fabs(rcVct.z);
Vector3<float_type> cVctRes;
cVctRes.x = x * (float_type)fabs(rcVct.x);
cVctRes.y = y * (float_type)fabs(rcVct.y);
cVctRes.z = z * (float_type)fabs(rcVct.z);
return cVctRes;
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::operator-(const Vector3<_Precision>& rcVct) const
template<class float_type>
Vector3<float_type> Vector3<float_type>::operator-(const Vector3<float_type>& rcVct) const
{
Vector3<_Precision> cVctRes;
Vector3<float_type> cVctRes;
cVctRes.x = x - rcVct.x;
cVctRes.y = y - rcVct.y;
cVctRes.z = z - rcVct.z;
return cVctRes;
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::operator-() const
template<class float_type>
Vector3<float_type> Vector3<float_type>::operator-() const
{
return Vector3(-x, -y, -z);
}
template<class _Precision>
Vector3<_Precision>& Vector3<_Precision>::operator+=(const Vector3<_Precision>& rcVct)
template<class float_type>
Vector3<float_type>& Vector3<float_type>::operator+=(const Vector3<float_type>& rcVct)
{
x += rcVct.x;
y += rcVct.y;
@@ -112,8 +112,8 @@ Vector3<_Precision>& Vector3<_Precision>::operator+=(const Vector3<_Precision>&
return *this;
}
template<class _Precision>
Vector3<_Precision>& Vector3<_Precision>::operator-=(const Vector3<_Precision>& rcVct)
template<class float_type>
Vector3<float_type>& Vector3<float_type>::operator-=(const Vector3<float_type>& rcVct)
{
x -= rcVct.x;
y -= rcVct.y;
@@ -121,8 +121,8 @@ Vector3<_Precision>& Vector3<_Precision>::operator-=(const Vector3<_Precision>&
return *this;
}
template<class _Precision>
Vector3<_Precision>& Vector3<_Precision>::operator*=(_Precision fScale)
template<class float_type>
Vector3<float_type>& Vector3<float_type>::operator*=(float_type fScale)
{
x *= fScale;
y *= fScale;
@@ -130,8 +130,8 @@ Vector3<_Precision>& Vector3<_Precision>::operator*=(_Precision fScale)
return *this;
}
template<class _Precision>
Vector3<_Precision>& Vector3<_Precision>::operator/=(_Precision fDiv)
template<class float_type>
Vector3<float_type>& Vector3<float_type>::operator/=(float_type fDiv)
{
x /= fDiv;
y /= fDiv;
@@ -139,58 +139,58 @@ Vector3<_Precision>& Vector3<_Precision>::operator/=(_Precision fDiv)
return *this;
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::operator*(_Precision fScale) const
template<class float_type>
Vector3<float_type> Vector3<float_type>::operator*(float_type fScale) const
{
return Vector3<_Precision>(this->x * fScale, this->y * fScale, this->z * fScale);
return Vector3<float_type>(this->x * fScale, this->y * fScale, this->z * fScale);
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::operator/(_Precision fDiv) const
template<class float_type>
Vector3<float_type> Vector3<float_type>::operator/(float_type fDiv) const
{
return Vector3<_Precision>(this->x / fDiv, this->y / fDiv, this->z / fDiv);
return Vector3<float_type>(this->x / fDiv, this->y / fDiv, this->z / fDiv);
}
template<class _Precision>
_Precision Vector3<_Precision>::operator*(const Vector3<_Precision>& rcVct) const
template<class float_type>
float_type Vector3<float_type>::operator*(const Vector3<float_type>& rcVct) const
{
return (x * rcVct.x) + (y * rcVct.y) + (z * rcVct.z);
}
template<class _Precision>
_Precision Vector3<_Precision>::Dot(const Vector3<_Precision>& rcVct) const
template<class float_type>
float_type Vector3<float_type>::Dot(const Vector3<float_type>& rcVct) const
{
return (x * rcVct.x) + (y * rcVct.y) + (z * rcVct.z);
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::operator%(const Vector3<_Precision>& rcVct) const
template<class float_type>
Vector3<float_type> Vector3<float_type>::operator%(const Vector3<float_type>& rcVct) const
{
Vector3<_Precision> cVctRes;
Vector3<float_type> cVctRes;
cVctRes.x = (y * rcVct.z) - (z * rcVct.y);
cVctRes.y = (z * rcVct.x) - (x * rcVct.z);
cVctRes.z = (x * rcVct.y) - (y * rcVct.x);
return cVctRes;
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::Cross(const Vector3<_Precision>& rcVct) const
template<class float_type>
Vector3<float_type> Vector3<float_type>::Cross(const Vector3<float_type>& rcVct) const
{
Vector3<_Precision> cVctRes;
Vector3<float_type> cVctRes;
cVctRes.x = (y * rcVct.z) - (z * rcVct.y);
cVctRes.y = (z * rcVct.x) - (x * rcVct.z);
cVctRes.z = (x * rcVct.y) - (y * rcVct.x);
return cVctRes;
}
template<class _Precision>
bool Vector3<_Precision>::IsOnLineSegment(const Vector3<_Precision>& startVct,
const Vector3<_Precision>& endVct) const
template<class float_type>
bool Vector3<float_type>::IsOnLineSegment(const Vector3<float_type>& startVct,
const Vector3<float_type>& endVct) const
{
Vector3<_Precision> vectorAB = endVct - startVct;
Vector3<_Precision> vectorAC = *this - startVct;
Vector3<_Precision> crossproduct = vectorAB.Cross(vectorAC);
_Precision dotproduct = vectorAB.Dot(vectorAC);
Vector3<float_type> vectorAB = endVct - startVct;
Vector3<float_type> vectorAC = *this - startVct;
Vector3<float_type> crossproduct = vectorAB.Cross(vectorAC);
float_type dotproduct = vectorAB.Dot(vectorAC);
if (crossproduct.Length() > traits_type::epsilon()) {
return false;
@@ -207,202 +207,202 @@ bool Vector3<_Precision>::IsOnLineSegment(const Vector3<_Precision>& startVct,
return true;
}
template<class _Precision>
bool Vector3<_Precision>::operator!=(const Vector3<_Precision>& rcVct) const
template<class float_type>
bool Vector3<float_type>::operator!=(const Vector3<float_type>& rcVct) const
{
return !((*this) == rcVct);
}
template<class _Precision>
bool Vector3<_Precision>::operator==(const Vector3<_Precision>& rcVct) const
template<class float_type>
bool Vector3<float_type>::operator==(const Vector3<float_type>& rcVct) const
{
return (std::fabs(x - rcVct.x) <= traits_type::epsilon())
&& (std::fabs(y - rcVct.y) <= traits_type::epsilon())
&& (std::fabs(z - rcVct.z) <= traits_type::epsilon());
}
template<class _Precision>
bool Vector3<_Precision>::IsEqual(const Vector3<_Precision>& rclPnt, _Precision tol) const
template<class float_type>
bool Vector3<float_type>::IsEqual(const Vector3<float_type>& rclPnt, float_type tol) const
{
return Distance(*this, rclPnt) <= tol;
}
template<class _Precision>
Vector3<_Precision>& Vector3<_Precision>::ProjectToPlane(const Vector3<_Precision>& rclBase,
const Vector3<_Precision>& rclNorm)
template<class float_type>
Vector3<float_type>& Vector3<float_type>::ProjectToPlane(const Vector3<float_type>& rclBase,
const Vector3<float_type>& rclNorm)
{
Vector3<_Precision> clTemp(rclNorm);
Vector3<float_type> clTemp(rclNorm);
*this = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr());
return *this;
}
template<class _Precision>
void Vector3<_Precision>::ProjectToPlane(const Vector3& rclBase,
template<class float_type>
void Vector3<float_type>::ProjectToPlane(const Vector3& rclBase,
const Vector3& rclNorm,
Vector3& rclProj) const
{
Vector3<_Precision> clTemp(rclNorm);
Vector3<float_type> clTemp(rclNorm);
rclProj = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr());
}
template<class _Precision>
_Precision Vector3<_Precision>::DistanceToPlane(const Vector3<_Precision>& rclBase,
const Vector3<_Precision>& rclNorm) const
template<class float_type>
float_type Vector3<float_type>::DistanceToPlane(const Vector3<float_type>& rclBase,
const Vector3<float_type>& rclNorm) const
{
return ((*this - rclBase) * rclNorm) / rclNorm.Length();
}
template<class _Precision>
_Precision Vector3<_Precision>::Length() const
template<class float_type>
float_type Vector3<float_type>::Length() const
{
return static_cast<_Precision>(std::sqrt((x * x) + (y * y) + (z * z)));
return static_cast<float_type>(std::sqrt((x * x) + (y * y) + (z * z)));
}
template<class _Precision>
_Precision Vector3<_Precision>::DistanceToLine(const Vector3<_Precision>& base,
const Vector3<_Precision>& dir) const
template<class float_type>
float_type Vector3<float_type>::DistanceToLine(const Vector3<float_type>& base,
const Vector3<float_type>& dir) const
{
// clang-format off
return static_cast<_Precision>(std::fabs((dir % Vector3(*this - base)).Length() / dir.Length()));
return static_cast<float_type>(std::fabs((dir % Vector3(*this - base)).Length() / dir.Length()));
// clang-format on
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::DistanceToLineSegment(const Vector3& rclP1,
template<class float_type>
Vector3<float_type> Vector3<float_type>::DistanceToLineSegment(const Vector3& rclP1,
const Vector3& rclP2) const
{
_Precision len2 = Base::DistanceP2(rclP1, rclP2);
float_type len2 = Base::DistanceP2(rclP1, rclP2);
if (len2 == 0) {
return rclP1;
}
Vector3<_Precision> p2p1 = rclP2 - rclP1;
Vector3<_Precision> pXp1 = *this - rclP1;
_Precision dot = pXp1 * p2p1;
_Precision t = clamp<_Precision>(dot / len2, 0, 1);
Vector3<_Precision> dist = t * p2p1 - pXp1;
Vector3<float_type> p2p1 = rclP2 - rclP1;
Vector3<float_type> pXp1 = *this - rclP1;
float_type dot = pXp1 * p2p1;
float_type t = clamp<float_type>(dot / len2, 0, 1);
Vector3<float_type> dist = t * p2p1 - pXp1;
return dist;
}
template<class _Precision>
Vector3<_Precision>& Vector3<_Precision>::ProjectToLine(const Vector3<_Precision>& rclPoint,
const Vector3<_Precision>& rclLine)
template<class float_type>
Vector3<float_type>& Vector3<float_type>::ProjectToLine(const Vector3<float_type>& rclPoint,
const Vector3<float_type>& rclLine)
{
return (*this = ((((rclPoint * rclLine) / rclLine.Sqr()) * rclLine) - rclPoint));
}
template<class _Precision>
Vector3<_Precision> Vector3<_Precision>::Perpendicular(const Vector3<_Precision>& rclBase,
const Vector3<_Precision>& rclDir) const
template<class float_type>
Vector3<float_type> Vector3<float_type>::Perpendicular(const Vector3<float_type>& rclBase,
const Vector3<float_type>& rclDir) const
{
_Precision t = ((*this - rclBase) * rclDir) / (rclDir * rclDir);
float_type t = ((*this - rclBase) * rclDir) / (rclDir * rclDir);
return rclBase + t * rclDir;
}
template<class _Precision>
_Precision Vector3<_Precision>::Sqr() const
template<class float_type>
float_type Vector3<float_type>::Sqr() const
{
return (_Precision)((x * x) + (y * y) + (z * z));
return (float_type)((x * x) + (y * y) + (z * z));
}
template<class _Precision>
void Vector3<_Precision>::Set(_Precision fX, _Precision fY, _Precision fZ)
template<class float_type>
void Vector3<float_type>::Set(float_type fX, float_type fY, float_type fZ)
{
x = fX;
y = fY;
z = fZ;
}
template<class _Precision>
void Vector3<_Precision>::ScaleX(_Precision f)
template<class float_type>
void Vector3<float_type>::ScaleX(float_type f)
{
x *= f;
}
template<class _Precision>
void Vector3<_Precision>::ScaleY(_Precision f)
template<class float_type>
void Vector3<float_type>::ScaleY(float_type f)
{
y *= f;
}
template<class _Precision>
void Vector3<_Precision>::ScaleZ(_Precision f)
template<class float_type>
void Vector3<float_type>::ScaleZ(float_type f)
{
z *= f;
}
template<class _Precision>
void Vector3<_Precision>::Scale(_Precision fX, _Precision fY, _Precision fZ)
template<class float_type>
void Vector3<float_type>::Scale(float_type fX, float_type fY, float_type fZ)
{
x *= fX;
y *= fY;
z *= fZ;
}
template<class _Precision>
void Vector3<_Precision>::MoveX(_Precision f)
template<class float_type>
void Vector3<float_type>::MoveX(float_type f)
{
x += f;
}
template<class _Precision>
void Vector3<_Precision>::MoveY(_Precision f)
template<class float_type>
void Vector3<float_type>::MoveY(float_type f)
{
y += f;
}
template<class _Precision>
void Vector3<_Precision>::MoveZ(_Precision f)
template<class float_type>
void Vector3<float_type>::MoveZ(float_type f)
{
z += f;
}
template<class _Precision>
void Vector3<_Precision>::Move(_Precision fX, _Precision fY, _Precision fZ)
template<class float_type>
void Vector3<float_type>::Move(float_type fX, float_type fY, float_type fZ)
{
x += fX;
y += fY;
z += fZ;
}
template<class _Precision>
void Vector3<_Precision>::RotateX(_Precision f)
template<class float_type>
void Vector3<float_type>::RotateX(float_type f)
{
Vector3 cPt(*this);
_Precision fsin = static_cast<_Precision>(sin(f));
_Precision fcos = static_cast<_Precision>(cos(f));
float_type fsin = static_cast<float_type>(sin(f));
float_type fcos = static_cast<float_type>(cos(f));
y = (cPt.y * fcos) - (cPt.z * fsin);
z = (cPt.y * fsin) + (cPt.z * fcos);
}
template<class _Precision>
void Vector3<_Precision>::RotateY(_Precision f)
template<class float_type>
void Vector3<float_type>::RotateY(float_type f)
{
Vector3 cPt(*this);
_Precision fsin = static_cast<_Precision>(sin(f));
_Precision fcos = static_cast<_Precision>(cos(f));
float_type fsin = static_cast<float_type>(sin(f));
float_type fcos = static_cast<float_type>(cos(f));
x = (cPt.z * fsin) + (cPt.x * fcos);
z = (cPt.z * fcos) - (cPt.x * fsin);
}
template<class _Precision>
void Vector3<_Precision>::RotateZ(_Precision f)
template<class float_type>
void Vector3<float_type>::RotateZ(float_type f)
{
Vector3 cPt(*this);
_Precision fsin = static_cast<_Precision>(sin(f));
_Precision fcos = static_cast<_Precision>(cos(f));
float_type fsin = static_cast<float_type>(sin(f));
float_type fcos = static_cast<float_type>(cos(f));
x = (cPt.x * fcos) - (cPt.y * fsin);
y = (cPt.x * fsin) + (cPt.y * fcos);
}
template<class _Precision>
Vector3<_Precision>& Vector3<_Precision>::Normalize()
template<class float_type>
Vector3<float_type>& Vector3<float_type>::Normalize()
{
_Precision fLen = Length();
if (fLen != static_cast<_Precision>(0.0) && fLen != static_cast<_Precision>(1.0)) {
float_type fLen = Length();
if (fLen != static_cast<float_type>(0.0) && fLen != static_cast<float_type>(1.0)) {
x /= fLen;
y /= fLen;
z /= fLen;
@@ -410,23 +410,23 @@ Vector3<_Precision>& Vector3<_Precision>::Normalize()
return *this;
}
template<class _Precision>
bool Vector3<_Precision>::IsNull() const
template<class float_type>
bool Vector3<float_type>::IsNull() const
{
_Precision n {0.0};
float_type n {0.0};
return (x == n) && (y == n) && (z == n);
}
template<class _Precision>
_Precision Vector3<_Precision>::GetAngle(const Vector3& rcVect) const
template<class float_type>
float_type Vector3<float_type>::GetAngle(const Vector3& rcVect) const
{
_Precision len1 = Length();
_Precision len2 = rcVect.Length();
float_type len1 = Length();
float_type len2 = rcVect.Length();
if (len1 <= traits_type::epsilon() || len2 <= traits_type::epsilon()) {
return std::numeric_limits<_Precision>::quiet_NaN(); // division by zero
return std::numeric_limits<float_type>::quiet_NaN(); // division by zero
}
_Precision dot = Dot(rcVect);
float_type dot = Dot(rcVect);
dot /= len1;
dot /= len2;
@@ -437,11 +437,11 @@ _Precision Vector3<_Precision>::GetAngle(const Vector3& rcVect) const
return 0.0;
}
return _Precision(acos(dot));
return float_type(acos(dot));
}
template<class _Precision>
void Vector3<_Precision>::TransformToCoordinateSystem(const Vector3& rclBase,
template<class float_type>
void Vector3<float_type>::TransformToCoordinateSystem(const Vector3& rclBase,
const Vector3& rclDirX,
const Vector3& rclDirY)
{