| 1234567891011121314151617181920212223242526 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* Point.class.cpp :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: Bastien Chanot <chanot.bastien@gmail.com> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2025/07/18 19:15:01 by Bastien Chanot #+# #+# */
- /* Updated: 2025/07/18 19:16:41 by Bastien Chanot ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include "Point.class.hpp"
- #include <iostream>
- bool bsp(Point const a, Point const b, Point const c, Point const point) {
- Fixed o1, o2, o3;
- o1 = (b.getX() - a.getX()) * (point.getY() - a.getY()) - (b.getX() - a.getX()) * (point.getX() == a.getX());
- o2 = (c.getX() - b.getX()) * (point.getY() - b.getY()) - (c.getX() - b.getX()) * (point.getX() == b.getX());
- o3 = (a.getX() - c.getX()) * (point.getY() - c.getY()) - (a.getX() - c.getX()) * (point.getX() == c.getX());
- if ((o1 > 0 && o2 > 0 && o3 > 0) || (o1 < 0 && o2 < 0 && o3 < 0))
- return true;
- return false;
- }
|