mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 13:46:13 +00:00
Add distSqTo to CAIVector
This commit is contained in:
parent
7cd7d0b913
commit
bf87d4d1c0
3 changed files with 19 additions and 0 deletions
|
@ -155,6 +155,11 @@ inline double CAIVectorMirror::distTo(const CAIPos &dest) const
|
|||
return (dest-CAIVector(*this)).norm();
|
||||
}
|
||||
|
||||
inline double CAIVectorMirror::distSqTo(const CAIPos &dest) const
|
||||
{
|
||||
return (dest-CAIVector(*this)).sqrnorm();
|
||||
}
|
||||
|
||||
inline double CAIVectorMirror::quickDistTo(const CAIPos &dest) const
|
||||
{
|
||||
double dx=fabs((dest.x()-x()).asDouble()), dy=fabs((dest.y()-y()).asDouble());
|
||||
|
@ -172,6 +177,11 @@ inline double CAIVectorMirror::distTo(const CAIVector &dest) const
|
|||
return (dest-CAIVector(*this)).norm();
|
||||
}
|
||||
|
||||
inline double CAIVectorMirror::distSqTo(const CAIVector &dest) const
|
||||
{
|
||||
return (dest-CAIVector(*this)).sqrnorm();
|
||||
}
|
||||
|
||||
inline double CAIVectorMirror::quickDistTo(const CAIVector &dest) const
|
||||
{
|
||||
double dx=fabs((dest.x()-x()).asDouble()), dy=fabs((dest.y()-y()).asDouble());
|
||||
|
@ -189,6 +199,11 @@ inline double CAIVectorMirror::distTo(const CAIVectorMirror &dest) const
|
|||
return (dest-*this).norm();
|
||||
}
|
||||
|
||||
inline double CAIVectorMirror::distSqTo(const CAIVectorMirror &dest) const
|
||||
{
|
||||
return (dest-*this).sqrnorm();
|
||||
}
|
||||
|
||||
inline double CAIVectorMirror::quickDistTo(const CAIVectorMirror &dest) const
|
||||
{
|
||||
double dx=fabs((dest.x()-x()).asDouble()), dy=fabs((dest.y()-y()).asDouble()); return (dx>dy)? (dx+dy/2): (dy+dx/2);
|
||||
|
|
|
@ -83,14 +83,17 @@ public: // Methods.
|
|||
// a few handy utility methods
|
||||
inline CAngle angleTo(const CAIPos &dest) const;
|
||||
inline double distTo(const CAIPos &dest) const;
|
||||
inline double distSqTo(const CAIPos &dest) const;
|
||||
inline double quickDistTo(const CAIPos &dest) const;
|
||||
|
||||
inline CAngle angleTo(const CAIVector &dest) const;
|
||||
inline double distTo(const CAIVector &dest) const;
|
||||
inline double distSqTo(const CAIVector &dest) const;
|
||||
inline double quickDistTo(const CAIVector &dest) const;
|
||||
|
||||
inline CAngle angleTo(const CAIVectorMirror &dest) const;
|
||||
inline double distTo(const CAIVectorMirror &dest) const;
|
||||
inline double distSqTo(const CAIVectorMirror &dest) const;
|
||||
inline double quickDistTo(const CAIVectorMirror &dest) const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -130,6 +130,7 @@ public: // Methods.
|
|||
template <class V> CAngle angleTo(const V &v) const { return CAngle(atan2((v.y()-y()).asDouble(),
|
||||
(v.x()-x()).asDouble())); }
|
||||
template <class V> double distTo(const V &v) const { return (*this-v).norm(); }
|
||||
template <class V> double distSqTo(const V &v) const { return (*this-v).sqrnorm(); }
|
||||
template <class V> double quickDistTo(const V &v) const { double dx=fabs((v.x()-x()).asDouble()),
|
||||
dy=fabs((v.y()-y()).asDouble());
|
||||
return (dx>dy)? (dx+dy/2): (dy+dx/2); }
|
||||
|
|
Loading…
Reference in a new issue