2015-10-14 15:32:53 +11:00
|
|
|
/*
|
2018-08-04 15:14:06 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2015-10-14 15:32:53 +11:00
|
|
|
*
|
2018-04-09 12:49:09 +10:00
|
|
|
* Copyright 2016-2018 Danny Robson <danny@nerdcruft.net>
|
2015-10-14 15:32:53 +11:00
|
|
|
*/
|
|
|
|
|
2018-04-09 12:49:09 +10:00
|
|
|
#include "tri.hpp"
|
2024-10-29 15:03:40 +11:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename T>
|
|
|
|
bool
|
|
|
|
cruft::geom::inclusive (tri2<T> const &obj, point2<T> const &p)
|
|
|
|
{
|
|
|
|
// Assumes ccw winding
|
|
|
|
CHECK (cross (obj.b - obj.a, obj.c - obj.a) > 0);
|
|
|
|
|
|
|
|
auto const sign = [] (
|
|
|
|
cruft::point2f const p_,
|
|
|
|
cruft::point2f const a_,
|
|
|
|
cruft::point2f const b_)
|
|
|
|
{
|
|
|
|
return cross (p_ - a_, b_ - a_);
|
|
|
|
};
|
|
|
|
|
|
|
|
return sign (p, obj.a, obj.b) <= 0
|
|
|
|
and sign (p, obj.b, obj.c) <= 0
|
|
|
|
and sign (p, obj.c, obj.a) <= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
template bool cruft::geom::inclusive (tri2<f32> const&, point2<f32> const&);
|