From 7b94547a73147de02fbcf87565011b4f8cee27ed Mon Sep 17 00:00:00 2001 From: Souriya Trinh Date: Sat, 11 May 2024 00:49:24 +0200 Subject: [PATCH] Fix segfault with vpThetaUVector and std::vector based-constructor. --- modules/core/src/math/transformation/vpThetaUVector.cpp | 2 +- modules/core/test/tools/io/testNPZ.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/core/src/math/transformation/vpThetaUVector.cpp b/modules/core/src/math/transformation/vpThetaUVector.cpp index 7d61de8150..da304f8745 100644 --- a/modules/core/src/math/transformation/vpThetaUVector.cpp +++ b/modules/core/src/math/transformation/vpThetaUVector.cpp @@ -101,7 +101,7 @@ vpThetaUVector::vpThetaUVector(double tux, double tuy, double tuz) : vpRotationV /*! Build a \f$\theta {\bf u}\f$ vector from a vector of 3 angles in radian. */ -vpThetaUVector::vpThetaUVector(const std::vector &tu) { buildFrom(tu); } +vpThetaUVector::vpThetaUVector(const std::vector &tu) : vpRotationVector(3) { buildFrom(tu); } /*! Converts an homogeneous matrix into a \f$\theta {\bf u}\f$ vector. diff --git a/modules/core/test/tools/io/testNPZ.cpp b/modules/core/test/tools/io/testNPZ.cpp index a1cec45dcf..7c4bdf4778 100644 --- a/modules/core/test/tools/io/testNPZ.cpp +++ b/modules/core/test/tools/io/testNPZ.cpp @@ -175,8 +175,7 @@ TEST_CASE("Test visp::cnpy::npy_load/npz_save", "[visp::cnpy I/O]") u[2] = i*4 + 2; u.normalize(); double theta = vpMath::rad(5*i + 2); - std::vector vec { theta*u[0], theta*u[1], theta*u[2] }; - vpThetaUVector tu(vec[0], vec[1], vec[2]); + vpThetaUVector tu(std::vector{ theta *u[0], theta *u[1], theta *u[2] }); // std::cout << "theta=" << tu.getTheta() << " ; u=" << tu.getU().transpose() << std::endl; vpTranslationVector trans(i*4 + 10, i*4 + 20, i*4 + 30);