Skip to content

Commit d14a365

Browse files
janherlingmeta-codesync[bot]
authored andcommitted
Fixed GravityConstraints
Summary: - Wrong validation check - Wrong alignment check Reviewed By: enpe Differential Revision: D87682495 Privacy Context Container: L1192943 fbshipit-source-id: 22f2c2ee8631390702352bd1d62460434a5ac8ed
1 parent eff8df2 commit d14a365

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

impl/ocean/geometry/GravityConstraints.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ class GravityConstraintsT;
3131
/**
3232
* Definition of the GravityConstraints object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single or double precision float data type.
3333
* @see GravityConstraintsT
34-
* @ingroup math
34+
* @ingroup geometry
3535
*/
3636
using GravityConstraints = GravityConstraintsT<Scalar>;
3737

3838
/**
3939
* Definition of the GravityConstraints object, using double floating point precision.
4040
* @see GravityConstraintsT
41-
* @ingroup math
41+
* @ingroup geometry
4242
*/
4343
using GravityConstraintsD = GravityConstraintsT<double>;
4444

4545
/**
4646
* Definition of the GravityConstraints object, using single floating point precision.
4747
* @see GravityConstraintsT
48-
* @ingroup math
48+
* @ingroup geometry
4949
*/
5050
using GravityConstraintsF = GravityConstraintsT<float>;
5151

@@ -80,7 +80,7 @@ class GravityConstraintsT
8080
* @param gravityInCamera The camera gravity vector (which is known for a camera pose), defined in the camera coordinate system, with default camera pointing towards the negative z-space and y-axis pointing upwards.
8181
* @param worldGravityInWorld The world gravity vector in the world coordinate system, mainly defining how the world coordinate system is oriented/aligned wrt gravity
8282
* @param weightFactor The weight factor to be used during a non-linear optimization of a camera pose; 0 to skip any gravity correction, 1 to apply a normal/default gravity correction, larger values to apply a stronger gravity correction, with range [0, infinity)
83-
* @param maximalAngle The maximal angle between world and camera gravity vector (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, in radian, with range [0, PI/2).
83+
* @param maximalAngle The maximal angle between world and camera gravity vector (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, basically specifying how accurate the gravity vector is, in radian, with range [0, PI/2)
8484
*/
8585
explicit inline GravityConstraintsT(const VectorT3<T>& cameraGravityInCamera, const VectorT3<T>& worldGravityInWorld = VectorT3<T>(0, -1, 0), const T weightFactor = T(1), const T maximalAngle = NumericT<T>::deg2rad(5));
8686

@@ -89,7 +89,7 @@ class GravityConstraintsT
8989
* @param gravityInCameras The camera gravity vectors (which are known for several camera poses), defined in the camera coordinate system, with default camera pointing towards the negative z-space and y-axis pointing upwards.
9090
* @param worldGravityInWorld The world gravity vector in the world coordinate system, mainly defining how the world coordinate system is oriented/aligned wrt gravity
9191
* @param weightFactor The weight factor to be used during a non-linear optimization of a camera pose; 0 to skip any gravity correction, 1 to apply a normal/default gravity correction, larger values to apply a stronger gravity correction, with range [0, infinity)
92-
* @param maximalAngle The maximal angle between world and camera gravity vectors (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, in radian, with range [0, PI/2).
92+
* @param maximalAngle The maximal angle between world and camera gravity vectors (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, basically specifying how accurate the gravity vector is, in radian, with range [0, PI/2)
9393
*/
9494
explicit inline GravityConstraintsT(VectorsT3<T>&& cameraGravityInCameras, const VectorT3<T>& worldGravityInWorld = VectorT3<T>(0, -1, 0), const T weightFactor = T(1), const T maximalAngle = NumericT<T>::deg2rad(5));
9595

@@ -99,7 +99,7 @@ class GravityConstraintsT
9999
* @param world_T_camera The transformation transforming camera to world, with default camera pointing towards the negative z-space and y-axis pointing upwards, must be valid
100100
* @param worldGravityInWorld The world gravity vector in the world coordinate system, mainly defining how the world coordinate system is oriented/aligned wrt gravity
101101
* @param weightFactor The weight factor to be used during a non-linear optimization of a camera pose; 0 to skip any gravity correction, 1 to apply a normal/default gravity correction, larger values to apply a stronger gravity correction, with range [0, infinity)
102-
* @param maximalAngle The maximal angle between world and camera gravity vector (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, in radian, with range [0, PI/2).
102+
* @param maximalAngle The maximal angle between world and camera gravity vector (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, basically specifying how accurate the gravity vector is, in radian, with range [0, PI/2)
103103
*/
104104
explicit inline GravityConstraintsT(const HomogenousMatrixT4<T>& world_T_camera, const VectorT3<T>& worldGravityInWorld = VectorT3<T>(0, -1, 0), const T weightFactor = T(1), const T maximalAngle = NumericT<T>::deg2rad(5));
105105

@@ -109,7 +109,7 @@ class GravityConstraintsT
109109
* @param world_T_cameras The transformations transforming camera to world, with default camera pointing towards the negative z-space and y-axis pointing upwards, must be valid
110110
* @param worldGravityInWorld The world gravity vector in the world coordinate system, mainly defining how the world coordinate system is oriented/aligned wrt gravity
111111
* @param weightFactor The weight factor to be used during a non-linear optimization of a camera pose; 0 to skip any gravity correction, 1 to apply a normal/default gravity correction, larger values to apply a stronger gravity correction, with range [0, infinity)
112-
* @param maximalAngle The maximal angle between world and camera gravity vectors (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, in radian, with range [0, PI/2).
112+
* @param maximalAngle The maximal angle between world and camera gravity vectors (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, basically specifying how accurate the gravity vector is, in radian, with range [0, PI/2)
113113
*/
114114
explicit inline GravityConstraintsT(const HomogenousMatricesT4<T>& world_T_cameras, const VectorT3<T>& worldGravityInWorld = VectorT3<T>(0, -1, 0), const T weightFactor = T(1), const T maximalAngle = NumericT<T>::deg2rad(5));
115115

@@ -244,23 +244,23 @@ class GravityConstraintsT
244244
inline T alignmentCosine(const QuaternionT<T>& world_Q_camera, const size_t cameraIndex = 0) const;
245245

246246
/**
247-
* Returns the cosine between the world gravity vector and the camera gravity vector (after converting into the same coordinate system), in radian
247+
* Returns the cosine between the world gravity vector and the camera gravity vector (after converting into the same coordinate system).
248248
* @param world_T_camera The transformation transforming camera to world, with a default camera pointing towards the negative z-space and y-axis pointing upwards, must be valid
249249
* @param cameraIndex The index of the camera for which the cosine will be returned, with range [0, numberCameras() - 1]
250250
* @return The cosine of the angle between the world gravity vector and the camera gravity vector, with range [-1, 1]
251251
*/
252252
inline T alignmentCosine(const HomogenousMatrixT4<T>& world_T_camera, const size_t cameraIndex = 0) const;
253253

254254
/**
255-
* Returns the cosine between the world gravity vector and the camera gravity vector (after converting into the same coordinate system), in radian
255+
* Returns the cosine between the world gravity vector and the camera gravity vector (after converting into the same coordinate system).
256256
* @param flippedCamera_Q_world The rotation rotating world to flipped camera, with a default flipped camera pointing towards the positive z-space and y-axis pointing downwards, must be valid
257257
* @param cameraIndex The index of the camera for which the cosine will be returned, with range [0, numberCameras() - 1]
258258
* @return The cosine of the angle between the world gravity vector and the camera gravity vector, with range [-1, 1]
259259
*/
260260
inline T alignmentCosineIF(const QuaternionT<T>& flippedCamera_Q_world, const size_t cameraIndex = 0) const;
261261

262262
/**
263-
* Returns the cosine between the world gravity vector and the camera gravity vector (after converting into the same coordinate system), in radian
263+
* Returns the cosine between the world gravity vector and the camera gravity vector (after converting into the same coordinate system).
264264
* @param flippedCamera_T_world The transformation transforming world to flipped camera, with a default flipped camera pointing towards the positive z-space and y-axis pointing downwards, must be valid
265265
* @param cameraIndex The index of the camera for which the cosine will be returned, with range [0, numberCameras() - 1]
266266
* @return The cosine of the angle between the world gravity vector and the camera gravity vector, with range [-1, 1]
@@ -378,10 +378,10 @@ class GravityConstraintsT
378378
HomogenousMatrixT4<T> alignCameraWithGravity(const HomogenousMatrixT4<T>& world_T_camera, const size_t cameraIndex = 0) const;
379379

380380
/**
381-
* Rotates a inverted and flipped camera pose so that the flipped camera is aligned with the gravity constraints.
381+
* Rotates an inverted and flipped camera pose so that the flipped camera is aligned with the gravity constraints.
382382
* @param flippedCamera_T_world The transformation transforming world to flipped camera, with a default flipped camera pointing towards the positive z-space and y-axis pointing downwards, must be valid
383383
* @param cameraIndex The index of the camera for which the alignment will be performed, with range [0, numberCameras() - 1]
384-
* @return The flipped inverted and flipped camera pose aligned with the gravity constraints (alignedFlippedCamera_T_world)
384+
* @return The inverted and flipped camera pose aligned with the gravity constraints (alignedFlippedCamera_T_world)
385385
*/
386386
HomogenousMatrixT4<T> alignCameraWithGravityIF(const HomogenousMatrixT4<T>& flippedCamera_T_world, const size_t cameraIndex = 0) const;
387387

@@ -418,7 +418,7 @@ class GravityConstraintsT
418418

419419
/**
420420
* Helper function returning the camera gravity vector in the camera coordinate system based on a given camera pose and the world gravity vector.
421-
* The resulting camera gravity vector is obtained by converting the world gravity vector into the camera coordinate system.,br>
421+
* The resulting camera gravity vector is obtained by converting the world gravity vector into the camera coordinate system.<br>
422422
* This function return the same gravity vector as cameraGravityInCamera(), but uses the flipped camera pose as input parameter.
423423
* @param flippedCamera_T_world The transformation transforming world to flipped camera, with default camera pointing towards the positive z-space and y-axis pointing downwards, must be valid
424424
* @param worldGravityInWorld The world gravity vector defined in the world coordinate system, must be a unit vector
@@ -444,7 +444,7 @@ class GravityConstraintsT
444444
/// The world gravity vector defined in the world coordinate system, mainly defining how the world coordinate system is oriented/aligned wrt gravity.
445445
VectorT3<T> worldGravityInWorld_ = VectorT3<T>(0, -1, 0);
446446

447-
/// The weight factor to be used during a non-linear optimization of a camera pose; 0 to skip any gravity correction, 1 to apply a full gravity correction; with range [0, 1).
447+
/// The weight factor to be used during a non-linear optimization of a camera pose; 0 to skip any gravity correction, 1 to apply a full gravity correction; with range [0, infinity).
448448
T weightFactor_ = T(-1);
449449

450450
/// The maximal angle between world and camera gravity vectors (when converted into the same coordinate system), can be used e.g., when the camera pose is determined e.g., with RANSAC or a PnP algorithm, in radian, with range [0, PI/2).
@@ -773,7 +773,7 @@ bool GravityConstraintsT<T>::isCameraAlignedWithGravityIF(const QuaternionT<T>&
773773
{
774774
ocean_assert(isValid());
775775

776-
return isCameraAlignedWithGravityIF(flippedCamera_Q_world, cameraIndex) >= minimalAngleCos_;
776+
return alignmentCosineIF(flippedCamera_Q_world, cameraIndex) >= minimalAngleCos_;
777777
}
778778

779779
template <typename T>
@@ -873,7 +873,7 @@ template <typename T>
873873
inline bool GravityConstraintsT<T>::isValid() const
874874
{
875875
const bool valid = weightFactor_ >= T(0)
876-
&& maximalAngle_ >= NumericT<T>::rad2deg(0) && maximalAngle_ <= NumericT<T>::rad2deg(90)
876+
&& maximalAngle_ >= NumericT<T>::deg2rad(0) && maximalAngle_ <= NumericT<T>::deg2rad(90)
877877
&& !cameraGravityInCameras_.isEmpty() && !worldGravityInWorld_.isNull();
878878

879879
#ifdef OCEAN_DEBUG

0 commit comments

Comments
 (0)