From 8b8f2647d0945791dd79934753de74fda43d9d61 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 20 Nov 2023 17:27:38 +0100 Subject: [PATCH] Base: fix bugprone reserved identifier --- .clang-tidy | 2 +- src/Base/Vector3D.cpp | 276 +++++++++++++++++++++--------------------- src/Base/Vector3D.h | 122 +++++++++---------- 3 files changed, 200 insertions(+), 200 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 38f21b8bfc..57b34e79e8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -152,7 +152,7 @@ CheckOptions: - key: google-readability-braces-around-statements.ShortStatementLines value: '1' - key: bugprone-reserved-identifier.AllowedIdentifiers - value: '_object;_Precision' + value: '_object' - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays value: 'false' - key: readability-else-after-return.WarnOnUnfixable diff --git a/src/Base/Vector3D.cpp b/src/Base/Vector3D.cpp index 16574df72c..3db1aa1f52 100644 --- a/src/Base/Vector3D.cpp +++ b/src/Base/Vector3D.cpp @@ -32,15 +32,15 @@ using namespace Base; -template -Vector3<_Precision>::Vector3(_Precision fx, _Precision fy, _Precision fz) +template +Vector3::Vector3(float_type fx, float_type fy, float_type fz) : x(fx) , y(fy) , z(fz) {} -template -_Precision& Vector3<_Precision>::operator[](unsigned short usIndex) +template +float_type& Vector3::operator[](unsigned short usIndex) { switch (usIndex) { case 0: @@ -53,8 +53,8 @@ _Precision& Vector3<_Precision>::operator[](unsigned short usIndex) return x; } -template -const _Precision& Vector3<_Precision>::operator[](unsigned short usIndex) const +template +const float_type& Vector3::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 -Vector3<_Precision> Vector3<_Precision>::operator+(const Vector3<_Precision>& rcVct) const +template +Vector3 Vector3::operator+(const Vector3& rcVct) const { - Vector3<_Precision> cVctRes; + Vector3 cVctRes; cVctRes.x = x + rcVct.x; cVctRes.y = y + rcVct.y; cVctRes.z = z + rcVct.z; return cVctRes; } -template -Vector3<_Precision> Vector3<_Precision>::operator&(const Vector3<_Precision>& rcVct) const +template +Vector3 Vector3::operator&(const Vector3& 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 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 -Vector3<_Precision> Vector3<_Precision>::operator-(const Vector3<_Precision>& rcVct) const +template +Vector3 Vector3::operator-(const Vector3& rcVct) const { - Vector3<_Precision> cVctRes; + Vector3 cVctRes; cVctRes.x = x - rcVct.x; cVctRes.y = y - rcVct.y; cVctRes.z = z - rcVct.z; return cVctRes; } -template -Vector3<_Precision> Vector3<_Precision>::operator-() const +template +Vector3 Vector3::operator-() const { return Vector3(-x, -y, -z); } -template -Vector3<_Precision>& Vector3<_Precision>::operator+=(const Vector3<_Precision>& rcVct) +template +Vector3& Vector3::operator+=(const Vector3& rcVct) { x += rcVct.x; y += rcVct.y; @@ -112,8 +112,8 @@ Vector3<_Precision>& Vector3<_Precision>::operator+=(const Vector3<_Precision>& return *this; } -template -Vector3<_Precision>& Vector3<_Precision>::operator-=(const Vector3<_Precision>& rcVct) +template +Vector3& Vector3::operator-=(const Vector3& rcVct) { x -= rcVct.x; y -= rcVct.y; @@ -121,8 +121,8 @@ Vector3<_Precision>& Vector3<_Precision>::operator-=(const Vector3<_Precision>& return *this; } -template -Vector3<_Precision>& Vector3<_Precision>::operator*=(_Precision fScale) +template +Vector3& Vector3::operator*=(float_type fScale) { x *= fScale; y *= fScale; @@ -130,8 +130,8 @@ Vector3<_Precision>& Vector3<_Precision>::operator*=(_Precision fScale) return *this; } -template -Vector3<_Precision>& Vector3<_Precision>::operator/=(_Precision fDiv) +template +Vector3& Vector3::operator/=(float_type fDiv) { x /= fDiv; y /= fDiv; @@ -139,58 +139,58 @@ Vector3<_Precision>& Vector3<_Precision>::operator/=(_Precision fDiv) return *this; } -template -Vector3<_Precision> Vector3<_Precision>::operator*(_Precision fScale) const +template +Vector3 Vector3::operator*(float_type fScale) const { - return Vector3<_Precision>(this->x * fScale, this->y * fScale, this->z * fScale); + return Vector3(this->x * fScale, this->y * fScale, this->z * fScale); } -template -Vector3<_Precision> Vector3<_Precision>::operator/(_Precision fDiv) const +template +Vector3 Vector3::operator/(float_type fDiv) const { - return Vector3<_Precision>(this->x / fDiv, this->y / fDiv, this->z / fDiv); + return Vector3(this->x / fDiv, this->y / fDiv, this->z / fDiv); } -template -_Precision Vector3<_Precision>::operator*(const Vector3<_Precision>& rcVct) const +template +float_type Vector3::operator*(const Vector3& rcVct) const { return (x * rcVct.x) + (y * rcVct.y) + (z * rcVct.z); } -template -_Precision Vector3<_Precision>::Dot(const Vector3<_Precision>& rcVct) const +template +float_type Vector3::Dot(const Vector3& rcVct) const { return (x * rcVct.x) + (y * rcVct.y) + (z * rcVct.z); } -template -Vector3<_Precision> Vector3<_Precision>::operator%(const Vector3<_Precision>& rcVct) const +template +Vector3 Vector3::operator%(const Vector3& rcVct) const { - Vector3<_Precision> cVctRes; + Vector3 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 -Vector3<_Precision> Vector3<_Precision>::Cross(const Vector3<_Precision>& rcVct) const +template +Vector3 Vector3::Cross(const Vector3& rcVct) const { - Vector3<_Precision> cVctRes; + Vector3 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 -bool Vector3<_Precision>::IsOnLineSegment(const Vector3<_Precision>& startVct, - const Vector3<_Precision>& endVct) const +template +bool Vector3::IsOnLineSegment(const Vector3& startVct, + const Vector3& endVct) const { - Vector3<_Precision> vectorAB = endVct - startVct; - Vector3<_Precision> vectorAC = *this - startVct; - Vector3<_Precision> crossproduct = vectorAB.Cross(vectorAC); - _Precision dotproduct = vectorAB.Dot(vectorAC); + Vector3 vectorAB = endVct - startVct; + Vector3 vectorAC = *this - startVct; + Vector3 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 -bool Vector3<_Precision>::operator!=(const Vector3<_Precision>& rcVct) const +template +bool Vector3::operator!=(const Vector3& rcVct) const { return !((*this) == rcVct); } -template -bool Vector3<_Precision>::operator==(const Vector3<_Precision>& rcVct) const +template +bool Vector3::operator==(const Vector3& 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 -bool Vector3<_Precision>::IsEqual(const Vector3<_Precision>& rclPnt, _Precision tol) const +template +bool Vector3::IsEqual(const Vector3& rclPnt, float_type tol) const { return Distance(*this, rclPnt) <= tol; } -template -Vector3<_Precision>& Vector3<_Precision>::ProjectToPlane(const Vector3<_Precision>& rclBase, - const Vector3<_Precision>& rclNorm) +template +Vector3& Vector3::ProjectToPlane(const Vector3& rclBase, + const Vector3& rclNorm) { - Vector3<_Precision> clTemp(rclNorm); + Vector3 clTemp(rclNorm); *this = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr()); return *this; } -template -void Vector3<_Precision>::ProjectToPlane(const Vector3& rclBase, +template +void Vector3::ProjectToPlane(const Vector3& rclBase, const Vector3& rclNorm, Vector3& rclProj) const { - Vector3<_Precision> clTemp(rclNorm); + Vector3 clTemp(rclNorm); rclProj = *this - (clTemp *= ((*this - rclBase) * clTemp) / clTemp.Sqr()); } -template -_Precision Vector3<_Precision>::DistanceToPlane(const Vector3<_Precision>& rclBase, - const Vector3<_Precision>& rclNorm) const +template +float_type Vector3::DistanceToPlane(const Vector3& rclBase, + const Vector3& rclNorm) const { return ((*this - rclBase) * rclNorm) / rclNorm.Length(); } -template -_Precision Vector3<_Precision>::Length() const +template +float_type Vector3::Length() const { - return static_cast<_Precision>(std::sqrt((x * x) + (y * y) + (z * z))); + return static_cast(std::sqrt((x * x) + (y * y) + (z * z))); } -template -_Precision Vector3<_Precision>::DistanceToLine(const Vector3<_Precision>& base, - const Vector3<_Precision>& dir) const +template +float_type Vector3::DistanceToLine(const Vector3& base, + const Vector3& dir) const { // clang-format off - return static_cast<_Precision>(std::fabs((dir % Vector3(*this - base)).Length() / dir.Length())); + return static_cast(std::fabs((dir % Vector3(*this - base)).Length() / dir.Length())); // clang-format on } -template -Vector3<_Precision> Vector3<_Precision>::DistanceToLineSegment(const Vector3& rclP1, +template +Vector3 Vector3::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 p2p1 = rclP2 - rclP1; + Vector3 pXp1 = *this - rclP1; + float_type dot = pXp1 * p2p1; + float_type t = clamp(dot / len2, 0, 1); + Vector3 dist = t * p2p1 - pXp1; return dist; } -template -Vector3<_Precision>& Vector3<_Precision>::ProjectToLine(const Vector3<_Precision>& rclPoint, - const Vector3<_Precision>& rclLine) +template +Vector3& Vector3::ProjectToLine(const Vector3& rclPoint, + const Vector3& rclLine) { return (*this = ((((rclPoint * rclLine) / rclLine.Sqr()) * rclLine) - rclPoint)); } -template -Vector3<_Precision> Vector3<_Precision>::Perpendicular(const Vector3<_Precision>& rclBase, - const Vector3<_Precision>& rclDir) const +template +Vector3 Vector3::Perpendicular(const Vector3& rclBase, + const Vector3& rclDir) const { - _Precision t = ((*this - rclBase) * rclDir) / (rclDir * rclDir); + float_type t = ((*this - rclBase) * rclDir) / (rclDir * rclDir); return rclBase + t * rclDir; } -template -_Precision Vector3<_Precision>::Sqr() const +template +float_type Vector3::Sqr() const { - return (_Precision)((x * x) + (y * y) + (z * z)); + return (float_type)((x * x) + (y * y) + (z * z)); } -template -void Vector3<_Precision>::Set(_Precision fX, _Precision fY, _Precision fZ) +template +void Vector3::Set(float_type fX, float_type fY, float_type fZ) { x = fX; y = fY; z = fZ; } -template -void Vector3<_Precision>::ScaleX(_Precision f) +template +void Vector3::ScaleX(float_type f) { x *= f; } -template -void Vector3<_Precision>::ScaleY(_Precision f) +template +void Vector3::ScaleY(float_type f) { y *= f; } -template -void Vector3<_Precision>::ScaleZ(_Precision f) +template +void Vector3::ScaleZ(float_type f) { z *= f; } -template -void Vector3<_Precision>::Scale(_Precision fX, _Precision fY, _Precision fZ) +template +void Vector3::Scale(float_type fX, float_type fY, float_type fZ) { x *= fX; y *= fY; z *= fZ; } -template -void Vector3<_Precision>::MoveX(_Precision f) +template +void Vector3::MoveX(float_type f) { x += f; } -template -void Vector3<_Precision>::MoveY(_Precision f) +template +void Vector3::MoveY(float_type f) { y += f; } -template -void Vector3<_Precision>::MoveZ(_Precision f) +template +void Vector3::MoveZ(float_type f) { z += f; } -template -void Vector3<_Precision>::Move(_Precision fX, _Precision fY, _Precision fZ) +template +void Vector3::Move(float_type fX, float_type fY, float_type fZ) { x += fX; y += fY; z += fZ; } -template -void Vector3<_Precision>::RotateX(_Precision f) +template +void Vector3::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(sin(f)); + float_type fcos = static_cast(cos(f)); y = (cPt.y * fcos) - (cPt.z * fsin); z = (cPt.y * fsin) + (cPt.z * fcos); } -template -void Vector3<_Precision>::RotateY(_Precision f) +template +void Vector3::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(sin(f)); + float_type fcos = static_cast(cos(f)); x = (cPt.z * fsin) + (cPt.x * fcos); z = (cPt.z * fcos) - (cPt.x * fsin); } -template -void Vector3<_Precision>::RotateZ(_Precision f) +template +void Vector3::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(sin(f)); + float_type fcos = static_cast(cos(f)); x = (cPt.x * fcos) - (cPt.y * fsin); y = (cPt.x * fsin) + (cPt.y * fcos); } -template -Vector3<_Precision>& Vector3<_Precision>::Normalize() +template +Vector3& Vector3::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(0.0) && fLen != static_cast(1.0)) { x /= fLen; y /= fLen; z /= fLen; @@ -410,23 +410,23 @@ Vector3<_Precision>& Vector3<_Precision>::Normalize() return *this; } -template -bool Vector3<_Precision>::IsNull() const +template +bool Vector3::IsNull() const { - _Precision n {0.0}; + float_type n {0.0}; return (x == n) && (y == n) && (z == n); } -template -_Precision Vector3<_Precision>::GetAngle(const Vector3& rcVect) const +template +float_type Vector3::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::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 -void Vector3<_Precision>::TransformToCoordinateSystem(const Vector3& rclBase, +template +void Vector3::TransformToCoordinateSystem(const Vector3& rclBase, const Vector3& rclDirX, const Vector3& rclDirY) { diff --git a/src/Base/Vector3D.h b/src/Base/Vector3D.h index e0c14dab98..03ca928e37 100644 --- a/src/Base/Vector3D.h +++ b/src/Base/Vector3D.h @@ -97,11 +97,11 @@ struct float_traits }; /** The Vector Base class. */ -template +template class Vector3 { public: - using num_type = _Precision; + using num_type = float_type; using traits_type = float_traits; static inline num_type epsilon() { @@ -110,90 +110,90 @@ public: /** @name Public data members */ //@{ - _Precision x; /**< x-coordinate */ - _Precision y; /**< y-coordinate */ - _Precision z; /**< z-coordinate */ + float_type x; /**< x-coordinate */ + float_type y; /**< y-coordinate */ + float_type z; /**< z-coordinate */ //@} /// Construction - explicit Vector3(_Precision fx = 0.0, _Precision fy = 0.0, _Precision fz = 0.0); - Vector3(const Vector3<_Precision>& v) = default; - Vector3(Vector3<_Precision>&& v) noexcept = default; + explicit Vector3(float_type fx = 0.0, float_type fy = 0.0, float_type fz = 0.0); + Vector3(const Vector3& v) = default; + Vector3(Vector3&& v) noexcept = default; ~Vector3() = default; /** @name Operator */ //@{ /// Returns a reference to a coordinate. \a usIndex must be in the range [0,2] - _Precision& operator[](unsigned short usIndex); + float_type& operator[](unsigned short usIndex); /// Returns a const reference to a coordinate. \a usIndex must be in the range [0,2] - const _Precision& operator[](unsigned short usIndex) const; + const float_type& operator[](unsigned short usIndex) const; /// Vector addition - Vector3 operator+(const Vector3<_Precision>& rcVct) const; - Vector3 operator&(const Vector3<_Precision>& rcVct) const; + Vector3 operator+(const Vector3& rcVct) const; + Vector3 operator&(const Vector3& rcVct) const; /// Vector subtraction - Vector3 operator-(const Vector3<_Precision>& rcVct) const; + Vector3 operator-(const Vector3& rcVct) const; /// Negative vector Vector3 operator-() const; /// Vector summation - Vector3& operator+=(const Vector3<_Precision>& rcVct); + Vector3& operator+=(const Vector3& rcVct); /// Vector subtraction - Vector3& operator-=(const Vector3<_Precision>& rcVct); + Vector3& operator-=(const Vector3& rcVct); /// Vector scaling - Vector3 operator*(_Precision fScale) const; - Vector3 operator/(_Precision fDiv) const; - Vector3& operator*=(_Precision fScale); - Vector3& operator/=(_Precision fDiv); + Vector3 operator*(float_type fScale) const; + Vector3 operator/(float_type fDiv) const; + Vector3& operator*=(float_type fScale); + Vector3& operator/=(float_type fDiv); /// Assignment - Vector3& operator=(const Vector3<_Precision>& v) = default; - Vector3& operator=(Vector3<_Precision>&& v) noexcept = default; + Vector3& operator=(const Vector3& v) = default; + Vector3& operator=(Vector3&& v) noexcept = default; /// Scalar product - _Precision operator*(const Vector3<_Precision>& rcVct) const; + float_type operator*(const Vector3& rcVct) const; /// Scalar product - _Precision Dot(const Vector3<_Precision>& rcVct) const; + float_type Dot(const Vector3& rcVct) const; /// Cross product - Vector3 operator%(const Vector3<_Precision>& rcVct) const; + Vector3 operator%(const Vector3& rcVct) const; /// Cross product - Vector3 Cross(const Vector3<_Precision>& rcVct) const; + Vector3 Cross(const Vector3& rcVct) const; /// Comparing for inequality - bool operator!=(const Vector3<_Precision>& rcVct) const; + bool operator!=(const Vector3& rcVct) const; /// Comparing for equality - bool operator==(const Vector3<_Precision>& rcVct) const; + bool operator==(const Vector3& rcVct) const; //@} /// Check if Vector is on a line segment - bool IsOnLineSegment(const Vector3<_Precision>& startVct, - const Vector3<_Precision>& endVct) const; + bool IsOnLineSegment(const Vector3& startVct, + const Vector3& endVct) const; /** @name Modification */ //@{ - void ScaleX(_Precision f); - void ScaleY(_Precision f); - void ScaleZ(_Precision f); - void Scale(_Precision fX, _Precision fY, _Precision fZ); - void MoveX(_Precision f); - void MoveY(_Precision f); - void MoveZ(_Precision f); - void Move(_Precision fX, _Precision fY, _Precision fZ); - void RotateX(_Precision f); - void RotateY(_Precision f); - void RotateZ(_Precision f); + void ScaleX(float_type f); + void ScaleY(float_type f); + void ScaleZ(float_type f); + void Scale(float_type fX, float_type fY, float_type fZ); + void MoveX(float_type f); + void MoveY(float_type f); + void MoveZ(float_type f); + void Move(float_type fX, float_type fY, float_type fZ); + void RotateX(float_type f); + void RotateY(float_type f); + void RotateZ(float_type f); //@} - void Set(_Precision fX, _Precision fY, _Precision fZ); + void Set(float_type fX, float_type fY, float_type fZ); /** @name Mathematics */ //@{ /// Length of the vector. - _Precision Length() const; + float_type Length() const; /// Squared length of the vector. - _Precision Sqr() const; + float_type Sqr() const; /// Set length to 1. Vector3& Normalize(); /// Checks whether this is the null vector bool IsNull() const; /// Get angle between both vectors. The returned value lies in the interval [0,pi]. - _Precision GetAngle(const Vector3& rcVect) const; + float_type GetAngle(const Vector3& rcVect) const; /** Transforms this point to the coordinate system defined by origin \a rclBase, * vector \a vector rclDirX and vector \a vector rclDirY. * \note \a rclDirX must be perpendicular to \a rclDirY, i.e. \a rclDirX * \a rclDirY = 0.. @@ -209,7 +209,7 @@ public: * If the distance to point \a rclPnt is within the tolerance \a tol both points are considered * equal. */ - bool IsEqual(const Vector3& rclPnt, _Precision tol) const; + bool IsEqual(const Vector3& rclPnt, float_type tol) const; /// Projects this point onto the plane given by the base \a rclBase and the normal \a rclNorm. Vector3& ProjectToPlane(const Vector3& rclBase, const Vector3& rclNorm); /** @@ -235,9 +235,9 @@ public: * the distance can also be negative. The distance is positive if the point is at the same * side the plane normal points to, negative otherwise. */ - _Precision DistanceToPlane(const Vector3& rclBase, const Vector3& rclNorm) const; + float_type DistanceToPlane(const Vector3& rclBase, const Vector3& rclNorm) const; /// Computes the distance from this point to the line given by \a rclBase and \a rclDirect. - _Precision DistanceToLine(const Vector3& rclBase, const Vector3& rclDirect) const; + float_type DistanceToLine(const Vector3& rclBase, const Vector3& rclDirect) const; /** Computes the vector from this point to the point on the line segment with the shortest * distance. The line segment is defined by \a rclP1 and \a rclP2. * Note: If the projection of this point is outside the segment then the shortest distance @@ -250,30 +250,30 @@ public: // global functions /// Returns the distance between two points -template -inline _Precision Distance(const Vector3<_Precision>& v1, const Vector3<_Precision>& v2) +template +inline float_type Distance(const Vector3& v1, const Vector3& v2) { - _Precision x = v1.x - v2.x; - _Precision y = v1.y - v2.y; - _Precision z = v1.z - v2.z; - return static_cast<_Precision>(sqrt((x * x) + (y * y) + (z * z))); + float_type x = v1.x - v2.x; + float_type y = v1.y - v2.y; + float_type z = v1.z - v2.z; + return static_cast(sqrt((x * x) + (y * y) + (z * z))); } /// Returns the squared distance between two points -template -inline _Precision DistanceP2(const Vector3<_Precision>& v1, const Vector3<_Precision>& v2) +template +inline float_type DistanceP2(const Vector3& v1, const Vector3& v2) { - _Precision x = v1.x - v2.x; - _Precision y = v1.y - v2.y; - _Precision z = v1.z - v2.z; + float_type x = v1.x - v2.x; + float_type y = v1.y - v2.y; + float_type z = v1.z - v2.z; return x * x + y * y + z * z; } /// Multiplication of scalar with vector. -template -inline Vector3<_Precision> operator*(_Precision fFac, const Vector3<_Precision>& rcVct) +template +inline Vector3 operator*(float_type fFac, const Vector3& rcVct) { - return Vector3<_Precision>(rcVct.x * fFac, rcVct.y * fFac, rcVct.z * fFac); + return Vector3(rcVct.x * fFac, rcVct.y * fFac, rcVct.z * fFac); } template