diff --git a/src/Math/Point2D.h b/src/Math/Point2D.h index 35ab1ff86..f0c85186a 100644 --- a/src/Math/Point2D.h +++ b/src/Math/Point2D.h @@ -58,6 +58,15 @@ template class Point2D: public Vector3 { */ inline constexpr Point2D(const Vector<2, T>& xy, T z = T(1)): Vector3(xy, z) {} + /** + * @brief Vector part of the point + * + * Equivalent to calling xy(). Useful for seamless 2D/3D integration. + * @see Point3D::vector() + */ + inline Vector2& vector() { return Vector3::xy(); } + inline constexpr Vector2 vector() const { return Vector3::xy(); } /**< @overload */ + MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Point2D, 3) MAGNUM_RECTANGULARMATRIX_SUBCLASS_OPERATOR_IMPLEMENTATION(1, 3, Point2D) }; diff --git a/src/Math/Point3D.h b/src/Math/Point3D.h index a1e8eda88..428a91395 100644 --- a/src/Math/Point3D.h +++ b/src/Math/Point3D.h @@ -59,6 +59,15 @@ template class Point3D: public Vector4 { */ inline constexpr Point3D(const Vector<3, T>& xyz, T w = T(1)): Vector4(xyz, w) {} + /** + * @brief Vector part of the point + * + * Equivalent to calling xyz(). Useful for seamless 2D/3D integration. + * @see Point2D::vector() + */ + inline Vector3& vector() { return Vector4::xyz(); } + inline constexpr Vector3 vector() const { return Vector4::xyz(); } /**< @overload */ + MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Point3D, 4) MAGNUM_RECTANGULARMATRIX_SUBCLASS_OPERATOR_IMPLEMENTATION(1, 4, Point3D) };