Removed toDegree arg from VectorI::AngleBetween
Former-commit-id: 6b5e141e7c291dadedbfd237f5f22615ce5dcfee
This commit is contained in:
parent
0e791ebb19
commit
2479588811
|
|
@ -23,7 +23,7 @@ class NzVector2
|
|||
|
||||
T AbsDotProduct(const NzVector2& vec) const;
|
||||
|
||||
T AngleBetween(const NzVector2& vec, bool toDegree = true) const;
|
||||
T AngleBetween(const NzVector2& vec) const;
|
||||
|
||||
T Distance(const NzVector2& vec) const;
|
||||
float Distancef(const NzVector2& vec) const;
|
||||
|
|
|
|||
|
|
@ -55,12 +55,9 @@ inline unsigned int NzVector2<unsigned int>::AbsDotProduct(const NzVector2<unsig
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector2<T>::AngleBetween(const NzVector2& vec, bool toDegree) const
|
||||
T NzVector2<T>::AngleBetween(const NzVector2& vec) const
|
||||
{
|
||||
if (toDegree)
|
||||
return NzRadianToDegree(std::atan2(vec.y, vec.x) - std::atan2(y, x));
|
||||
else
|
||||
return std::atan2(vec.y, vec.x) - std::atan2(y, x);
|
||||
return NzRadians(std::atan2(vec.y, vec.x) - std::atan2(y, x));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ template<typename T> class NzVector3
|
|||
|
||||
T AbsDotProduct(const NzVector3& vec) const;
|
||||
|
||||
T AngleBetween(const NzVector3& vec, bool toDegree = true) const;
|
||||
T AngleBetween(const NzVector3& vec) const;
|
||||
|
||||
NzVector3 CrossProduct(const NzVector3& vec) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -61,10 +61,10 @@ inline unsigned int NzVector3<unsigned int>::AbsDotProduct(const NzVector3<unsig
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T NzVector3<T>::AngleBetween(const NzVector3& vec, bool toDegree) const
|
||||
T NzVector3<T>::AngleBetween(const NzVector3& vec) const
|
||||
{
|
||||
T alpha = DotProduct(vec);
|
||||
T divisor = (GetLength() * vec.GetLength());
|
||||
// sqrt(a) * sqrt(b) = sqrt(a*b)
|
||||
T divisor = std::sqrt(GetSquaredLength() * vec.GetSquaredLength());
|
||||
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (NzNumberEquals(divisor, F(0.0)))
|
||||
|
|
@ -76,12 +76,8 @@ T NzVector3<T>::AngleBetween(const NzVector3& vec, bool toDegree) const
|
|||
}
|
||||
#endif
|
||||
|
||||
alpha /= divisor;
|
||||
|
||||
if (toDegree)
|
||||
return NzRadianToDegree(std::acos(NzClamp(alpha, F(-1.0), F(1.0))));
|
||||
else
|
||||
return std::acos(NzClamp(alpha, F(-1.0), F(1.0)));
|
||||
T alpha = DotProduct(vec)/divisor;
|
||||
return NzRadians(std::acos(NzClamp(alpha, F(-1.0), F(1.0))));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -478,8 +474,8 @@ template<typename T>
|
|||
bool NzVector3<T>::operator==(const NzVector3& vec) const
|
||||
{
|
||||
return NzNumberEquals(x, vec.x) &&
|
||||
NzNumberEquals(y, vec.y) &&
|
||||
NzNumberEquals(z, vec.z);
|
||||
NzNumberEquals(y, vec.y) &&
|
||||
NzNumberEquals(z, vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
Loading…
Reference in New Issue