A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Plane.hh
1#pragma once
2
3#include "egg/math/Vector.hh"
4
5namespace EGG {
6
10struct Plane3f {
12 Plane3f() = default;
13
15 Plane3f(const Vector3f &point, const Vector3f &normal) {
16 set(point, normal);
17 }
18
20 ~Plane3f() = default;
21
23 void set(const Vector3f &point, const Vector3f &normal) {
24 n = normal;
25 d = -(normal.dot(point));
26 }
27
29 [[nodiscard]] bool testPoint(const Vector3f &point) const {
30 return d + n.dot(point) <= 0.0f;
31 }
32
34 f32 d;
35};
36
37} // namespace EGG
EGG core library.
Definition Archive.cc:6
Represents a plane in 3D space, expressed with n.dot(x) = d for point x on the plane.
Definition Plane.hh:10
f32 d
Negated dot product. n.dot(x) = d => n.dot(x) - d = 0.
Definition Plane.hh:34
Vector3f n
Plane normal.
Definition Plane.hh:33
A 3D float vector.
Definition Vector.hh:88
f32 dot(const Vector3f &rhs) const
The dot product between two vectors.
Definition Vector.hh:187