123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- #ifndef _MPOINT2_H_
- #define _MPOINT2_H_
- #ifndef _MMATHFN_H_
- #include "math/mMathFn.h"
- #endif
- //------------------------------------------------------------------------------
- /// 2D integer point
- ///
- /// Uses S32 internally.
- class Point2I
- {
- //-------------------------------------- Public data
- public:
- S32 x; ///< X position
- S32 y; ///< Y position
- //-------------------------------------- Public interface
- public:
- Point2I(); ///< Create an uninitialized point.
- Point2I(const Point2I&); ///< Copy constructor
- Point2I(S32 in_x, S32 in_y); ///< Create point from two co-ordinates.
- //-------------------------------------- Non-math mutators and misc functions
- void set(S32 in_x, S32 in_y); ///< Set (x,y) position
- void setMin(const Point2I&); ///< Store lesser co-ordinates from parameter in this point.
- void setMax(const Point2I&); ///< Store greater co-ordinates from parameter in this point.
- void zero(); ///< Zero all values
- //-------------------------------------- Math mutators
- void neg(); ///< Invert sign of point's co-ordinates.
- void convolve(const Point2I&); ///< Convolve this point by parameter.
- //-------------------------------------- Queries
- bool isZero() const; ///< Is this point at the origin? (No epsilon used)
- F32 len() const; ///< Get the length of the point
- S32 lenSquared() const; ///< Get the length-squared of the point
- //-------------------------------------- Overloaded operators
- public:
- operator S32*() { return &x; }
- operator const S32*() const { return &x; }
- // Comparison operators
- bool operator==(const Point2I&) const;
- bool operator!=(const Point2I&) const;
- // Arithmetic w/ other points
- Point2I operator+(const Point2I&) const;
- Point2I operator-(const Point2I&) const;
- Point2I& operator+=(const Point2I&);
- Point2I& operator-=(const Point2I&);
- // Arithmetic w/ scalars
- Point2I operator*(S32) const;
- Point2I& operator*=(S32);
- Point2I operator/(S32) const;
- Point2I& operator/=(S32);
- Point2I operator*(const Point2I&) const;
- Point2I& operator*=(const Point2I&);
- Point2I operator/(const Point2I&) const;
- Point2I& operator/=(const Point2I&);
- // Unary operators
- Point2I operator-() const;
- //-------------------------------------- Public static constants
- public:
- const static Point2I One;
- const static Point2I Zero;
- const static Point2I Min;
- const static Point2I Max;
- };
- //------------------------------------------------------------------------------
- /// 2D floating-point point.
- class Point2F
- {
- //-------------------------------------- Public data
- public:
- F32 x;
- F32 y;
- public:
- Point2F(); ///< Create uninitialized point.
- Point2F(const Point2F&); ///< Copy constructor
- Point2F(F32 _x, F32 _y); ///< Create point from co-ordinates.
- //-------------------------------------- Non-math mutators and misc functions
- public:
- void set(F32 _x, F32 _y); ///< Set point's co-ordinates.
- void setMin(const Point2F&); ///< Store lesser co-ordinates.
- void setMax(const Point2F&); ///< Store greater co-ordinates.
- /// Interpolate from a to b, based on c.
- ///
- /// @param a Starting point.
- /// @param b Ending point.
- /// @param c Interpolation factor (0.0 .. 1.0).
- void interpolate(const Point2F& a, const Point2F& b, const F32 c);
- void zero(); ///< Zero all values
- operator F32*() { return &x; }
- operator const F32*() const { return &x; }
- //-------------------------------------- Queries
- public:
- bool isZero() const; ///< Check for zero coordinates. (No epsilon.)
- F32 len() const; ///< Get length.
- F32 lenSquared() const; ///< Get squared length (one sqrt less than len()).
- bool equal( const Point2F &compare ) const; ///< Is compare within POINT_EPSILON of all of the component of this point
- F32 magnitudeSafe() const;
- //-------------------------------------- Mathematical mutators
- public:
- void neg(); ///< Invert signs of co-ordinates.
- void normalize(); ///< Normalize vector.
- void normalize(F32 val); ///< Normalize, scaling by val.
- void normalizeSafe();
- void convolve(const Point2F&); ///< Convolve by parameter.
- void convolveInverse(const Point2F&); ///< Inversely convolute by parameter. (ie, divide)
- void rotate( F32 radians ); ///< Rotate vector around origin.
- /// Return a perpendicular vector to this one. The result is equivalent to rotating the
- /// vector 90 degrees clockwise around the origin.
- Point2F getPerpendicular() const { return Point2F( y, - x ); }
- //-------------------------------------- Overloaded operators
- public:
- // Comparison operators
- bool operator==(const Point2F&) const;
- bool operator!=(const Point2F&) const;
- // Arithmetic w/ other points
- Point2F operator+(const Point2F&) const;
- Point2F operator-(const Point2F&) const;
- Point2F& operator+=(const Point2F&);
- Point2F& operator-=(const Point2F&);
- // Arithmetic w/ scalars
- Point2F operator*(F32) const;
- Point2F operator/(F32) const;
- Point2F& operator*=(F32);
- Point2F& operator/=(F32);
- Point2F operator*(const Point2F&) const;
- Point2F& operator*=(const Point2F&);
- Point2F operator/(const Point2F&) const;
- Point2F& operator/=(const Point2F&);
- // Unary operators
- Point2F operator-() const;
- //-------------------------------------- Public static constants
- public:
- const static Point2F One;
- const static Point2F Zero;
- const static Point2F Min;
- const static Point2F Max;
- };
- //------------------------------------------------------------------------------
- /// 2D high-precision point.
- ///
- /// Uses F64 internally.
- class Point2D
- {
- //-------------------------------------- Public data
- public:
- F64 x; ///< X co-ordinate.
- F64 y; ///< Y co-ordinate.
- public:
- Point2D(); ///< Create uninitialized point.
- Point2D(const Point2D&); ///< Copy constructor
- Point2D(F64 _x, F64 _y); ///< Create point from coordinates.
- //-------------------------------------- Non-math mutators and misc functions
- public:
- void set(F64 _x, F64 _y); ///< Set point's coordinates.
- void setMin(const Point2D&); ///< Store lesser co-ordinates.
- void setMax(const Point2D&); ///< Store greater co-ordinates.
- /// Interpolate from a to b, based on c.
- ///
- /// @param a Starting point.
- /// @param b Ending point.
- /// @param c Interpolation factor (0.0 .. 1.0).
- void interpolate(const Point2D &a, const Point2D &b, const F64 c);
- void zero(); ///< Zero all values
- operator F64*() { return &x; }
- operator const F64*() const { return &x; }
- //-------------------------------------- Queries
- public:
- bool isZero() const;
- F64 len() const;
- F64 lenSquared() const;
- //-------------------------------------- Mathematical mutators
- public:
- void neg();
- void normalize();
- void normalize(F64 val);
- void convolve(const Point2D&);
- void convolveInverse(const Point2D&);
- //-------------------------------------- Overloaded operators
- public:
- // Comparison operators
- bool operator==(const Point2D&) const;
- bool operator!=(const Point2D&) const;
- // Arithmetic w/ other points
- Point2D operator+(const Point2D&) const;
- Point2D operator-(const Point2D&) const;
- Point2D& operator+=(const Point2D&);
- Point2D& operator-=(const Point2D&);
- // Arithmetic w/ scalars
- Point2D operator*(F64) const;
- Point2D operator/(F64) const;
- Point2D& operator*=(F64);
- Point2D& operator/=(F64);
- // Unary operators
- Point2D operator-() const;
- //-------------------------------------- Public static constants
- public:
- const static Point2D One;
- const static Point2D Zero;
- };
- //------------------------------------------------------------------------------
- //-------------------------------------- Point2I
- //
- inline Point2I::Point2I()
- :x(0),y(0)
- {
- }
- inline Point2I::Point2I(const Point2I& _copy)
- : x(_copy.x), y(_copy.y)
- {
- //
- }
- inline Point2I::Point2I(S32 _x, S32 _y)
- : x(_x), y(_y)
- {
- //
- }
- inline void Point2I::set(S32 _x, S32 _y)
- {
- x = _x;
- y = _y;
- }
- inline void Point2I::setMin(const Point2I& _test)
- {
- x = (_test.x < x) ? _test.x : x;
- y = (_test.y < y) ? _test.y : y;
- }
- inline void Point2I::setMax(const Point2I& _test)
- {
- x = (_test.x > x) ? _test.x : x;
- y = (_test.y > y) ? _test.y : y;
- }
- inline void Point2I::zero()
- {
- x = y = 0;
- }
- inline void Point2I::neg()
- {
- x = -x;
- y = -y;
- }
- inline void Point2I::convolve(const Point2I& c)
- {
- x *= c.x;
- y *= c.y;
- }
- inline bool Point2I::isZero() const
- {
- return ((x == 0) && (y == 0));
- }
- inline F32 Point2I::len() const
- {
- return mSqrt(F32(x*x + y*y));
- }
- inline S32 Point2I::lenSquared() const
- {
- return x*x + y*y;
- }
- inline bool Point2I::operator==(const Point2I& _test) const
- {
- return ((x == _test.x) && (y == _test.y));
- }
- inline bool Point2I::operator!=(const Point2I& _test) const
- {
- return (operator==(_test) == false);
- }
- inline Point2I Point2I::operator+(const Point2I& _add) const
- {
- return Point2I(x + _add.x, y + _add.y);
- }
- inline Point2I Point2I::operator-(const Point2I& _rSub) const
- {
- return Point2I(x - _rSub.x, y - _rSub.y);
- }
- inline Point2I& Point2I::operator+=(const Point2I& _add)
- {
- x += _add.x;
- y += _add.y;
- return *this;
- }
- inline Point2I& Point2I::operator-=(const Point2I& _rSub)
- {
- x -= _rSub.x;
- y -= _rSub.y;
- return *this;
- }
- inline Point2I Point2I::operator-() const
- {
- return Point2I(-x, -y);
- }
- inline Point2I Point2I::operator*(S32 mul) const
- {
- return Point2I(x * mul, y * mul);
- }
- inline Point2I Point2I::operator/(S32 div) const
- {
- AssertFatal(div != 0, "Error, div by zero attempted");
- return Point2I(x/div, y/div);
- }
- inline Point2I& Point2I::operator*=(S32 mul)
- {
- x *= mul;
- y *= mul;
- return *this;
- }
- inline Point2I& Point2I::operator/=(S32 div)
- {
- AssertFatal(div != 0, "Error, div by zero attempted");
- x /= div;
- y /= div;
- return *this;
- }
- inline Point2I Point2I::operator*(const Point2I &_vec) const
- {
- return Point2I(x * _vec.x, y * _vec.y);
- }
- inline Point2I& Point2I::operator*=(const Point2I &_vec)
- {
- x *= _vec.x;
- y *= _vec.y;
- return *this;
- }
- inline Point2I Point2I::operator/(const Point2I &_vec) const
- {
- return Point2I(x / _vec.x, y / _vec.y);
- }
- inline Point2I& Point2I::operator/=(const Point2I &_vec)
- {
- AssertFatal(_vec.x != 0 && _vec.y != 0, "Error, div by zero attempted");
- x /= _vec.x;
- y /= _vec.y;
- return *this;
- }
- //------------------------------------------------------------------------------
- //-------------------------------------- Point2F
- //
- inline Point2F::Point2F()
- :x(0.0f), y(0.0f)
- {
- }
- inline Point2F::Point2F(const Point2F& _copy)
- : x(_copy.x), y(_copy.y)
- {
- //
- }
- inline Point2F::Point2F(F32 _x, F32 _y)
- : x(_x), y(_y)
- {
- }
- inline void Point2F::set(F32 _x, F32 _y)
- {
- x = _x;
- y = _y;
- }
- inline void Point2F::setMin(const Point2F& _test)
- {
- x = (_test.x < x) ? _test.x : x;
- y = (_test.y < y) ? _test.y : y;
- }
- inline void Point2F::setMax(const Point2F& _test)
- {
- x = (_test.x > x) ? _test.x : x;
- y = (_test.y > y) ? _test.y : y;
- }
- inline void Point2F::interpolate(const Point2F& _rFrom, const Point2F& _to, const F32 _factor)
- {
- AssertFatal(_factor >= 0.0f && _factor <= 1.0f, "Out of bound interpolation factor");
- x = (_rFrom.x * (1.0f - _factor)) + (_to.x * _factor);
- y = (_rFrom.y * (1.0f - _factor)) + (_to.y * _factor);
- }
- inline void Point2F::zero()
- {
- x = y = 0.0f;
- }
- inline bool Point2F::isZero() const
- {
- return (x == 0.0f) && (y == 0.0f);
- }
- inline F32 Point2F::lenSquared() const
- {
- return (x * x) + (y * y);
- }
- inline bool Point2F::equal( const Point2F &compare ) const
- {
- return( ( mFabs( x - compare.x ) < POINT_EPSILON ) &&
- ( mFabs( y - compare.y ) < POINT_EPSILON ) );
- }
- inline void Point2F::neg()
- {
- x = -x;
- y = -y;
- }
- inline void Point2F::convolve(const Point2F& c)
- {
- x *= c.x;
- y *= c.y;
- }
- inline void Point2F::convolveInverse(const Point2F& c)
- {
- x /= c.x;
- y /= c.y;
- }
- inline void Point2F::rotate( F32 radians )
- {
- F32 sinTheta, cosTheta;
- mSinCos( radians, sinTheta, cosTheta );
- set( cosTheta * x - sinTheta * y,
- sinTheta * x + cosTheta * y );
- }
- inline bool Point2F::operator==(const Point2F& _test) const
- {
- return (x == _test.x) && (y == _test.y);
- }
- inline bool Point2F::operator!=(const Point2F& _test) const
- {
- return operator==(_test) == false;
- }
- inline Point2F Point2F::operator+(const Point2F& _add) const
- {
- return Point2F(x + _add.x, y + _add.y);
- }
- inline Point2F Point2F::operator-(const Point2F& _rSub) const
- {
- return Point2F(x - _rSub.x, y - _rSub.y);
- }
- inline Point2F& Point2F::operator+=(const Point2F& _add)
- {
- x += _add.x;
- y += _add.y;
- return *this;
- }
- inline Point2F& Point2F::operator-=(const Point2F& _rSub)
- {
- x -= _rSub.x;
- y -= _rSub.y;
- return *this;
- }
- inline Point2F Point2F::operator*(F32 _mul) const
- {
- return Point2F(x * _mul, y * _mul);
- }
- inline Point2F Point2F::operator/(F32 _div) const
- {
- AssertFatal(_div != 0.0f, "Error, div by zero attempted");
- F32 inv = 1.0f / _div;
- return Point2F(x * inv, y * inv);
- }
- inline Point2F& Point2F::operator*=(F32 _mul)
- {
- x *= _mul;
- y *= _mul;
- return *this;
- }
- inline Point2F& Point2F::operator/=(F32 _div)
- {
- AssertFatal(_div != 0.0f, "Error, div by zero attempted");
- F32 inv = 1.0f / _div;
- x *= inv;
- y *= inv;
- return *this;
- }
- inline Point2F Point2F::operator*(const Point2F &_vec) const
- {
- return Point2F(x * _vec.x, y * _vec.y);
- }
- inline Point2F& Point2F::operator*=(const Point2F &_vec)
- {
- x *= _vec.x;
- y *= _vec.y;
- return *this;
- }
- inline Point2F Point2F::operator/(const Point2F &_vec) const
- {
- return Point2F(x / _vec.x, y / _vec.y);
- }
- inline Point2F& Point2F::operator/=(const Point2F &_vec)
- {
- AssertFatal(_vec.x != 0 && _vec.y != 0, "Error, div by zero attempted");
- x /= _vec.x;
- y /= _vec.y;
- return *this;
- }
- inline Point2F Point2F::operator-() const
- {
- return Point2F(-x, -y);
- }
- inline F32 Point2F::len() const
- {
- return mSqrt(x*x + y*y);
- }
- inline void Point2F::normalize()
- {
- m_point2F_normalize(*this);
- }
- inline void Point2F::normalize(F32 val)
- {
- m_point2F_normalize_f(*this, val);
- }
- inline F32 Point2F::magnitudeSafe() const
- {
- if( isZero() )
- return 0.0f;
- else
- return len();
- }
- inline void Point2F::normalizeSafe()
- {
- F32 vmag = magnitudeSafe();
- if( vmag > POINT_EPSILON )
- *this *= F32(1.0 / vmag);
- }
- //------------------------------------------------------------------------------
- //-------------------------------------- Point2D
- //
- inline Point2D::Point2D()
- :x(0.0), y(0.0)
- {
- }
- inline Point2D::Point2D(const Point2D& _copy)
- : x(_copy.x), y(_copy.y)
- {
- //
- }
- inline Point2D::Point2D(F64 _x, F64 _y)
- : x(_x), y(_y)
- {
- }
- inline void Point2D::set(F64 _x, F64 _y)
- {
- x = _x;
- y = _y;
- }
- inline void Point2D::setMin(const Point2D& _test)
- {
- x = (_test.x < x) ? _test.x : x;
- y = (_test.y < y) ? _test.y : y;
- }
- inline void Point2D::setMax(const Point2D& _test)
- {
- x = (_test.x > x) ? _test.x : x;
- y = (_test.y > y) ? _test.y : y;
- }
- inline void Point2D::interpolate(const Point2D& _rFrom, const Point2D& _to, const F64 _factor)
- {
- AssertFatal(_factor >= 0.0f && _factor <= 1.0f, "Out of bound interpolation factor");
- x = (_rFrom.x * (1.0f - _factor)) + (_to.x * _factor);
- y = (_rFrom.y * (1.0f - _factor)) + (_to.y * _factor);
- }
- inline void Point2D::zero()
- {
- x = y = 0.0;
- }
- inline bool Point2D::isZero() const
- {
- return (x == 0.0f) && (y == 0.0f);
- }
- inline F64 Point2D::lenSquared() const
- {
- return (x * x) + (y * y);
- }
- inline void Point2D::neg()
- {
- x = -x;
- y = -y;
- }
- inline void Point2D::convolve(const Point2D& c)
- {
- x *= c.x;
- y *= c.y;
- }
- inline void Point2D::convolveInverse(const Point2D& c)
- {
- x /= c.x;
- y /= c.y;
- }
- inline bool Point2D::operator==(const Point2D& _test) const
- {
- return (x == _test.x) && (y == _test.y);
- }
- inline bool Point2D::operator!=(const Point2D& _test) const
- {
- return operator==(_test) == false;
- }
- inline Point2D Point2D::operator+(const Point2D& _add) const
- {
- return Point2D(x + _add.x, y + _add.y);
- }
- inline Point2D Point2D::operator-(const Point2D& _rSub) const
- {
- return Point2D(x - _rSub.x, y - _rSub.y);
- }
- inline Point2D& Point2D::operator+=(const Point2D& _add)
- {
- x += _add.x;
- y += _add.y;
- return *this;
- }
- inline Point2D& Point2D::operator-=(const Point2D& _rSub)
- {
- x -= _rSub.x;
- y -= _rSub.y;
- return *this;
- }
- inline Point2D Point2D::operator*(F64 _mul) const
- {
- return Point2D(x * _mul, y * _mul);
- }
- inline Point2D Point2D::operator/(F64 _div) const
- {
- AssertFatal(_div != 0.0f, "Error, div by zero attempted");
- F64 inv = 1.0f / _div;
- return Point2D(x * inv, y * inv);
- }
- inline Point2D& Point2D::operator*=(F64 _mul)
- {
- x *= _mul;
- y *= _mul;
- return *this;
- }
- inline Point2D& Point2D::operator/=(F64 _div)
- {
- AssertFatal(_div != 0.0f, "Error, div by zero attempted");
- F64 inv = 1.0f / _div;
- x *= inv;
- y *= inv;
- return *this;
- }
- inline Point2D Point2D::operator-() const
- {
- return Point2D(-x, -y);
- }
- inline F64 Point2D::len() const
- {
- return mSqrtD(x*x + y*y);
- }
- inline void Point2D::normalize()
- {
- m_point2D_normalize(*this);
- }
- inline void Point2D::normalize(F64 val)
- {
- m_point2D_normalize_f(*this, val);
- }
- //-------------------------------------------------------------------
- // Non-Member Operators
- //-------------------------------------------------------------------
- inline Point2I operator*(S32 mul, const Point2I& multiplicand)
- {
- return multiplicand * mul;
- }
- inline Point2F operator*(F32 mul, const Point2F& multiplicand)
- {
- return multiplicand * mul;
- }
- inline Point2D operator*(F64 mul, const Point2D& multiplicand)
- {
- return multiplicand * mul;
- }
- inline F32 mDot(const Point2F &p1, const Point2F &p2)
- {
- return (p1.x*p2.x + p1.y*p2.y);
- }
- inline F32 mDotPerp(const Point2F &p1, const Point2F &p2)
- {
- return p1.x*p2.y - p2.x*p1.y;
- }
- inline bool mIsNaN( const Point2F &p )
- {
- return mIsNaN_F( p.x ) || mIsNaN_F( p.y );
- }
- /// Return 0 if points are colinear
- /// Return positive if p0p1p2 are counter-clockwise
- /// Return negative if p0p1p2 are clockwise
- inline F64 mCross(const Point2F &p0, const Point2F &p1, const Point2F &pt2)
- {
- return (p1.x - p0.x) * (pt2.y - p0.y) - (p1.y - p0.y) * (pt2.x - p0.x);
- }
- namespace DictHash
- {
- /// Generates a 32bit hash from a Point2I.
- /// @see DictHash
- inline U32 hash( const Point2I &key )
- {
- return (key.x * 2230148873u) ^ key.y;
- }
- }
- #endif // _MPOINT2_H_
|