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

@@ -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

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)
{

View File

@@ -97,11 +97,11 @@ struct float_traits<double>
};
/** The Vector Base class. */
template<class _Precision>
template<class float_type>
class Vector3
{
public:
using num_type = _Precision;
using num_type = float_type;
using traits_type = float_traits<num_type>;
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<float_type>& v) = default;
Vector3(Vector3<float_type>&& 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<float_type>& rcVct) const;
Vector3 operator&(const Vector3<float_type>& rcVct) const;
/// Vector subtraction
Vector3 operator-(const Vector3<_Precision>& rcVct) const;
Vector3 operator-(const Vector3<float_type>& rcVct) const;
/// Negative vector
Vector3 operator-() const;
/// Vector summation
Vector3& operator+=(const Vector3<_Precision>& rcVct);
Vector3& operator+=(const Vector3<float_type>& rcVct);
/// Vector subtraction
Vector3& operator-=(const Vector3<_Precision>& rcVct);
Vector3& operator-=(const Vector3<float_type>& 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<float_type>& v) = default;
Vector3& operator=(Vector3<float_type>&& v) noexcept = default;
/// Scalar product
_Precision operator*(const Vector3<_Precision>& rcVct) const;
float_type operator*(const Vector3<float_type>& rcVct) const;
/// Scalar product
_Precision Dot(const Vector3<_Precision>& rcVct) const;
float_type Dot(const Vector3<float_type>& rcVct) const;
/// Cross product
Vector3 operator%(const Vector3<_Precision>& rcVct) const;
Vector3 operator%(const Vector3<float_type>& rcVct) const;
/// Cross product
Vector3 Cross(const Vector3<_Precision>& rcVct) const;
Vector3 Cross(const Vector3<float_type>& rcVct) const;
/// Comparing for inequality
bool operator!=(const Vector3<_Precision>& rcVct) const;
bool operator!=(const Vector3<float_type>& rcVct) const;
/// Comparing for equality
bool operator==(const Vector3<_Precision>& rcVct) const;
bool operator==(const Vector3<float_type>& 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<float_type>& startVct,
const Vector3<float_type>& 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<class _Precision>
inline _Precision Distance(const Vector3<_Precision>& v1, const Vector3<_Precision>& v2)
template<class float_type>
inline float_type Distance(const Vector3<float_type>& v1, const Vector3<float_type>& 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<float_type>(sqrt((x * x) + (y * y) + (z * z)));
}
/// Returns the squared distance between two points
template<class _Precision>
inline _Precision DistanceP2(const Vector3<_Precision>& v1, const Vector3<_Precision>& v2)
template<class float_type>
inline float_type DistanceP2(const Vector3<float_type>& v1, const Vector3<float_type>& 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<class _Precision>
inline Vector3<_Precision> operator*(_Precision fFac, const Vector3<_Precision>& rcVct)
template<class float_type>
inline Vector3<float_type> operator*(float_type fFac, const Vector3<float_type>& rcVct)
{
return Vector3<_Precision>(rcVct.x * fFac, rcVct.y * fFac, rcVct.z * fFac);
return Vector3<float_type>(rcVct.x * fFac, rcVct.y * fFac, rcVct.z * fFac);
}
template<class Pr1, class Pr2>