diff --git a/src/Math/Point2D.h b/src/Math/Point2D.h index 702eea7e3..6172707ba 100644 --- a/src/Math/Point2D.h +++ b/src/Math/Point2D.h @@ -54,7 +54,14 @@ template class Point2D: public Vector3 { * @param xy Two-component vector * @param z Z component */ - inline constexpr /*implicit*/ Point2D(const Vector2& xy, T z = T(1)): Vector3(xy, z) {} + inline constexpr /*implicit*/ Point2D(const Vector2& xy, T z): Vector3(xy, z) {} + + /** + * @brief Construct 2D point from 2D vector + * + * Z component is set to `1`. + */ + inline constexpr explicit Point2D(const Vector2& xy): Vector3(xy, T(1)) {} /** @copydoc Vector::Vector(const Vector&) */ template inline constexpr explicit Point2D(const Vector<3, U>& other): Vector3(other) {} diff --git a/src/Math/Point3D.h b/src/Math/Point3D.h index 13ff4c473..a30e9c8ff 100644 --- a/src/Math/Point3D.h +++ b/src/Math/Point3D.h @@ -55,7 +55,14 @@ template class Point3D: public Vector4 { * @param xyz Three-component vector * @param w W component */ - inline constexpr /*implicit*/ Point3D(const Vector3& xyz, T w = T(1)): Vector4(xyz, w) {} + inline constexpr /*implicit*/ Point3D(const Vector3& xyz, T w): Vector4(xyz, w) {} + + /** + * @brief Construct 3D point from 3D vector + * + * W component is set to `1`. + */ + inline constexpr explicit Point3D(const Vector3& xyz): Vector4(xyz, T(1)) {} /** @copydoc Vector::Vector(const Vector&) */ template inline constexpr explicit Point3D(const Vector<4, U>& other): Vector4(other) {} diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index 744c4cace..aae9352a2 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -48,6 +48,7 @@ class Matrix3Test: public Corrade::TestSuite::Tester { typedef Math::Matrix3 Matrix3; typedef Math::Matrix<2, float> Matrix2; typedef Math::Vector2 Vector2; +typedef Math::Point2D Point2D; Matrix3Test::Matrix3Test() { addTests(&Matrix3Test::constructIdentity, @@ -122,7 +123,7 @@ void Matrix3Test::reflection() { {0.0f, 0.0f, 1.0f}); CORRADE_COMPARE(actual*actual, Matrix3()); - CORRADE_COMPARE(actual*normal, -normal); + CORRADE_COMPARE((actual*Point2D(normal)).vector(), -normal); CORRADE_COMPARE(actual, expected); } diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp index 53e9f6d96..e3734870e 100644 --- a/src/Math/Test/Matrix4Test.cpp +++ b/src/Math/Test/Matrix4Test.cpp @@ -53,6 +53,7 @@ class Matrix4Test: public Corrade::TestSuite::Tester { typedef Math::Matrix4 Matrix4; typedef Math::Matrix<3, float> Matrix3; typedef Math::Vector3 Vector3; +typedef Math::Point3D Point3D; Matrix4Test::Matrix4Test() { addTests(&Matrix4Test::constructIdentity, @@ -170,7 +171,7 @@ void Matrix4Test::reflection() { { 0.0f, 0.0f, 0.0f, 1.0f}); CORRADE_COMPARE(actual*actual, Matrix4()); - CORRADE_COMPARE(actual*normal, -normal); + CORRADE_COMPARE((actual*Point3D(normal)).vector(), -normal); CORRADE_COMPARE(actual, expected); } diff --git a/src/Primitives/Icosphere.cpp b/src/Primitives/Icosphere.cpp index d5e79bbf8..0be978c15 100644 --- a/src/Primitives/Icosphere.cpp +++ b/src/Primitives/Icosphere.cpp @@ -54,7 +54,8 @@ Icosphere<0>::Icosphere(): MeshData3D(Mesh::Primitive::Triangles, new std::vecto {0.0f, 0.525731f, -0.850651f}, {0.0f, 0.525731f, 0.850651f} }}, {}) { - positions(0)->assign(normals(0)->begin(), normals(0)->end()); + positions(0)->reserve(normals(0)->size()); + for(auto i: *normals(0)) positions(0)->push_back(Point3D(i)); } }}