diff --git a/Engine/src/Runtime/Core/public/Math/Plane.hpp b/Engine/src/Runtime/Core/public/Math/Plane.hpp index ab9492b..3a42faa 100644 --- a/Engine/src/Runtime/Core/public/Math/Plane.hpp +++ b/Engine/src/Runtime/Core/public/Math/Plane.hpp @@ -15,8 +15,184 @@ namespace Phanes::Core::Math { public: TVector3 normal; T d; + + public: + + /** + * Default constructor. + */ + + TPlane() = default; + + /** + * Copy constructor + */ + + TPlane(const TPlane& plane) : normal(plane.normal), d(plane.d) {}; + + /** + * Move constructor + */ + + TPlane(TPlane&& plane) : + normal(std::move(plane.normal)), + d(std::move(plane.d)) + {} + + + /** + * Construct plane from normal and d + * + * @param(normal) Normal of plane + * @param(d) Scalar component + * + * @note Normal is NOT normalized, make sure to normalize [PARAM]normal, or use [FUNC]CreateFromVector. Otherwise unexpected results may occur using the plane. + */ + + TPlane(const TVector3& normal, T d) : + normal(normal), + d(d) + {} + + /** + * Construct plane from normal and base point. + * + * @param(normal) Normal of plane + * @param(base) Base point + */ + + TPlane(const TVector3& normal, const TVector3& base) : + normal(normal) + { + this->d = DotP(this->normal, base); + } + + /** + * Construct plane from coefficients + * + * @param(x) X coefficient + * @param(y) Y coefficient + * @param(z) Z coefficient + * @param(d) D coefficient + */ + + TPlane(T x, T y, T z, T d) : + d(d) + { + this->normal = TVector3(x, y, z); + } + + /** + * Construct plane from 3 points + * + * @param(p1) Point one + * @param(p2) Point two + * @param(p3) Point three + */ + + TPlane(const TVector3& p1, const TVector3& p2, const TVector3& p3) + { + this->normal = Normalize(CrossP(p1, p2)); + this->d = DotP(this->normal, p3); + } }; + /** + * Get dot product between two planes + * + * @param(pl1) Plane one + * @param(pl2) Plane two + */ + + template + FORCEINLINE T PlaneDotP(const TPlane& pl1, const TPlane& pl2) + { + return DotP(pl1.normal, pl2.normal); + } + + /** + * Get angle between two planes + * + * @param(pl1) Plane one + * @param(pl2) Plane two + */ + + template + FORCEINLINE T PlaneAngle(const TPlane& pl1, const TPlane& pl2) + { + return Angle(pl1.normal, pl2.normal); + } + + /** + * Get cosine of angle between two planes + * + * @param(pl1) Plane one + * @param(pl2) Plane two + */ + + template + FORCEINLINE T PlaneCosAngle(const TPlane& pl1, const TPlane& pl2) + { + return CosineAngle(pl1.normal, pl2.normal); + } + + /** + * Flip plane. + * + * @param(pl1) Plane + */ + + template + TPlane FlipV(const TPlane& pl1) + { + pl1.normal = -pl1.normal; + pl1.d = -pl1.d; + } + + + /** + * Get flipped plane. + * + * @param(pl1) Plane + * + * @return Flipped plane + */ + + template + TPlane Flip(const TPlane& pl1) + { + return TPlane(-pl1.normal, -pl1.d); + } + + /** + * Transform plane with Transform + * + * @param(pl) Plane + * @param(tr) Transform + */ + + template + FORCEINLINE TPlane TransformV(TPlane& pl, const TTransform& tr) + { + // TODO: Do with operator* + } + + + /** + * Transform plane with Transform + * + * @param(pl) Plane + * @param(tr) Transform + * + * @return Transformed plane. + */ + + template + FORCEINLINE TPlane Transform(const TPlane& pl, const TTransform& tr) + { + // TODO: Do with operator* + } + /** * Projects vector onto plane *