summaryrefslogtreecommitdiff
path: root/lib/geometricPlane.h
blob: c74befff542010f70f12c6982501495117dc2574 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include "config/types.h"
#include <glm/vec3.hpp>
#include <optional>

class Ray;

class GeometricPlane {
public:
	struct DistAndPosition {
		float dist;
		Position3D position;
	};
	enum class PlaneRelation { Above, Below, On };

	Position3D origin;
	Normal3D normal;

	[[nodiscard]] PlaneRelation getRelation(Position3D point) const;
	[[nodiscard]] std::optional<DistAndPosition> getRayIntersectPosition(const Ray &) const;

	static bool isIntersect(PlaneRelation a, PlaneRelation b);
};