| 123456789101112131415161718192021222324252627282930 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* bsp.cpp :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* 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 <iostream>
- 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;
- }
|