/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* bsp.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bchanot +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/18 19:15:01 by Bastien Cha #+# #+# */ /* Updated: 2025/12/18 13:11:51 by bchanot ### ########.fr */ /* */ /* ************************************************************************** */ #include "Point.class.hpp" #include Fixed orient(Point const & a, Point const & b, Point const & p) { return (b.getX() - a.getX()) * (p.getY() - a.getY()) - (b.getY() - a.getY()) * (p.getX() - a.getX()); } bool bsp(Point const & a, Point const & b, Point const & c, Point const & point) { Fixed o1, o2, o3; o1 = orient(a, b, point); o2 = orient(b, c, point); o3 = orient(c, a, point); if ((o1 > 0 && o2 > 0 && o3 > 0) || (o1 < 0 && o2 < 0 && o3 < 0)) return true; return false; }