#pragma once #include "Core/public/Math/Boilerplate.h" #include "Core/public/Math/MathCommon.hpp" #include "Core/public/Math/MathAbstractTypes.h" #include "Core/public/Math/MathFwd.h" #include "Core/public/Math/Vector2.hpp" #include "Core/public/Math/Vector3.hpp" #ifndef P_DEBUG #pragma warning(disable : 4244) #endif /** * The Point is the same as a vector. The type exists, to ensure * differentiation between the two types. */ #ifndef POINT_H #define POINT_H namespace Phanes::Core::Math { /** * A 2D Point with components x and y with float precision. */ template struct TPoint2 : public TVector2 { using TVector2::TVector2; using Real = T; /** * Creates Point2 from Point3's xy * * @param a Point3 one */ TPoint2(const TPoint3& p) { this->x = p.x; this->y = p.y; } /** * Creates Point2 from Point4's xy * * @param a Point4 one */ TPoint2(const TPoint4& p) { this->x = p.x; this->y = p.y; } }; /** * Calculates distance between two points. * * @param(p1) Point one * @param(p2) Point two * * @return Distance between two points. */ template T Distance(const TPoint2& p1, const TPoint2& p2) { return Magnitude(p2 - p1); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * A 3D Point with components x and y with float precision. */ template struct TPoint3 : public TVector3 { using TVector3::TVector3; using Real = T; /** * Creates Point3 from Point2's xy and zero * * @param a Point2 one */ TPoint3(const TPoint2& p) { this->x = p.x; this->y = p.y; this->z = 0; } /** * Creates Point3 from Point4's xyz * * @param a Point4 one */ TPoint3(const TPoint4& p) { this->x = p.x; this->y = p.y; this->z = p.z; } }; /** * Calculates distance between two points. * * @param(p1) Point one * @param(p2) Point two * * @return Distance between two points. */ template T Distance(const TPoint3& p1, const TPoint3& p2) { return Magnitude(p2 - p1); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * A 4D Point with components x and y with float precision. */ template struct TPoint4 : public TVector4 { using TVector4::TVector4; /** * Creates Point4 from Point2's xy and the last two zero * * @param a Point2 one */ TPoint4(const TPoint2& p) { this->x = p.x; this->y = p.y; this->z = 0; this->w = 0; } /** * Creates Point4 from Point3's xyz and zero * * @param a Point3 one */ TPoint4(const TPoint3& p) { this->x = p.x; this->y = p.y; this->z = p.z; this->w = 0; } }; /** * Calculates distance between two points. * * @param(p1) Point one * @param(p2) Point two * * @return Distance between two points. */ template T Distance(const TPoint4& p1, const TPoint4& p2) { return Magnitude(p2 - p1); } } // phanes::core::math::coretypes #endif // !POINT_H