credit to @MusicMonkey5555 for spotting. asserts for Div/NULLs with mutli-element classes

Also includes his magnitude and normalize safe alts
This commit is contained in:
Azaezel 2015-08-12 03:41:49 -05:00
parent c9bf6b1ae5
commit 4d3db61e94
3 changed files with 39 additions and 1 deletions

View file

@ -438,6 +438,7 @@ inline Point2I Point2I::operator/(const Point2I &_vec) const
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;
@ -645,6 +646,7 @@ inline Point2F Point2F::operator/(const Point2F &_vec) const
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;
@ -908,6 +910,14 @@ 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
{