Commit Graph

17 Commits

Author SHA1 Message Date
Sergiu Deitsch 06de7240c4 Restore quaternion group action
Commit 370631f01f rescaled the quaternion
manifold's group action so the tangent vector norm matches the full
rotation angle, addressing issue #941. While both conventions are
mathematically valid, issue #311 already concluded that the half-angle
one should be kept because too much code depends on it. The rescaling
effectively broke that expectation for existing callers.

Restore the pre-370631f01f71db36b580e5a65790b2a8d9559821 scaling, keep
the rest of that commit's cleanup, and update the documentation and
tests to match.

Fixes #1190

Change-Id: I1dd189c51153ed62cc8c871472aacb87673ec351
2026-07-31 21:00:38 +02:00
Sergiu Deitsch 8c50a34a1c Reuse rotation functionality in (Eigen)QuaternionManifold
Allow to specify the memory layout of quaternion coefficients using a
template parameter which defaults to Ceres coefficients order.

The changes are, for the most part, backwards compatible unless the
floating-point type is explicitly specified, e.g., as
&ceres::QuaternionToAngleAxis<double> to obtain a pointer to the
corresponding function. In such rare use cases, the coefficients order
must be given explicitly first as
ceres::QuaternionToAngleAxis<ceres::CeresQuaternionOrder>. In normal
situations, however, this should not be needed.

Change-Id: I05dd80f0593672dec656cc785cf06fe5268aee74
2025-06-19 18:15:51 +02:00
Sergiu Deitsch 370631f01f Use Euler parameters in QuaternionPlusImpl
Define the relation between the axis-angle representation of a rotation
and the corresponding unit quaternion as

  q(𝐞) = cos(𝜃/2) + sin(𝜃/2)/𝜃·𝐞

where 𝐞 = 𝜃𝛚 is the rotation vector given by the rotation angle 𝜃 and
the unit axis of rotation 𝛚 instead of

  q(𝐞) = cos(𝜃) + sin(𝜃)/𝜃·𝐞 .

This brings the former relation closer to the available functionality
provided by ceres/rotation.h.

Fixes #941

Change-Id: Id40c065f78593887ecc52e67a068737d7eb5bda6
2025-06-13 16:23:24 -07:00
Sameer Agarwal ebb66e655f ceres::internal::FixedArray -> absl::FixedArray
Ceres Solver was using an old forked version of FixedArray,
now that we are using absl, we can use the official version
that ships with it.

Change-Id: Ic88d7f6e8a49b928d611f7cbb04172452b322b01
2024-07-23 13:45:45 -07:00
Sameer Agarwal 0a53aa9054 Take abseil as a dependency
1. Add abseil-cpp as a submodule. We are tracking the latest LTS
release, which is lts_2024_01_16.
2. Replace glog/gflags with absl::log and absl::flags.
3. Remove miniglog
4. Also take a whack at making the bazel build work with
   abseil-cpp and gtest.

There are a number of TODOs in this CL that still need to be resolved.

Change-Id: I39355ed7d61375be4ebcbc8596d9cc70acc1c678
2024-07-18 00:24:49 -07:00
Alexander Ivanov f1113c08ab Commenting unused parameters for better readibility
Change-Id: Idc285fa68ba787636a69a3ea3350e0282b9f8569
2023-01-12 17:25:42 +00:00
Sergiu Deitsch cb6b306623 Use hypot to compute the L^2 norm
Change-Id: I908eaaa279452aa16346dfd3f25aac53685e3172
2023-01-05 21:44:53 +01:00
Sergiu Deitsch 7743d2e73c Store ProductManifold instances in a tuple
Since the number of manifolds used to initialize ProductManifold and
their types are known at compile-time, it is possible to avoid storing
pointers to the base class as required by a homogeneous, currently
dynamically sized container. Instead, we can use std::tuple<> as a
heterogenous container with the number of elements fixed at compile-time
that allows us to store the concrete manifold realizations.

The advantage of this approach is that we can bypass the vtable when
iterating over each manifold within ProductManifold. The indirection is
invoked only once while accessing the ProductManifoldImpl members.
Additionally, potential dynamic memory allocations by a std::vector can
be completely avoided. This makes the ProductManifold implementation
more efficient both in memory and runtime.

Change-Id: Ic71b0c175ab726f8992e9703f7666bca477baf19
2022-03-02 23:57:10 +00:00
Sameer Agarwal 6a37fbf9b4 Add static/compile time sizing to EuclideanManifold
This brings it in line with other manifolds like SphereManifold
and LineManifold, where the user has the choice to specify the size
of the manifold at compile time or runtime.

Most of the time the size is known at compile time so this will
speed up the common case.

Change-Id: I0c7ff8b7a9a64a81203eb11afc074874e208815a
2022-03-01 09:34:23 -08:00
Sergiu Deitsch f0851667be Fix MSVC compilation errors
Disable the definition of `min`/`max` macros by defining `NOMINMAX`
and prevent macro substitution in the public interface.

Also, quiet floating-point comparisons are defined as template functions
by the MSVC STL which causes compilation errors due to ambiguities in
resolving the template parameter types.

Fixes #668
Fixes #716
Fixes #718

Change-Id: I5fe7832a6a3a7ad0421a2557527528c34b88e9c7
2022-02-27 13:24:42 +01:00
Sergiu Deitsch c14f360e63 Drop trivial special members
Do not define trivial constructors or destructors unless necessary
(e.g., for implementing pimpl) following the rule of zero. Define
virtual base class destructors out-of-line to avoid emitting vtables in
every translation unit.

Change-Id: Iea2d8978e62a8ee5a97b86cbb4e858d56e0fb274
2022-02-09 21:30:14 +01:00
Sameer Agarwal 19eef54fc2 Rename Quaternion to QuaternionManifold.
Also rename EigenQuaternion to EigenQuaternionManiold.

Change-Id: I7095fa61cfabf97a328b02fb027f5a2a8dd499ae
2022-01-22 11:07:52 -08:00
Sameer Agarwal 00bfbae11f Add missing algorithm header to manifold.cc
Change-Id: I6211c65658ee124fc6a6587923e3ceadca76e24a
2022-01-12 20:44:45 -08:00
Sameer Agarwal fbd693091d Fix two unused variable warnings.
Change-Id: Iaabb47ea45aa09d92b911df79b4f2fd7ee60ae15
2022-01-12 06:03:23 -08:00
Sameer Agarwal 7e2f9d9d41 Add EigenQuaternion manifold and tests for it.
Change-Id: I579a45a2921424a07d03b3b4d9cfcbc0ab529f9b
2022-01-11 14:40:21 -08:00
Sameer Agarwal b81a8bbb7a Add the Quaternion manifold and tests.
Change-Id: I0a396a5834168c1526d6f2b8c99a1ad3348ad657
2022-01-07 04:59:02 -08:00
Sameer Agarwal 23b204d7e6 LocalParameterization -> Manifold #1
This is the first in a series of changes that will eventually
replace the LocalParameterization interface with the richer
Manifold interface.

1. Add the Manifold interface.
2. Add implementations and test for:
   a. EuclideanManifold (formerly the IdentityParameterization)
   b. SubsetManifold (formerly the SubsetParameterization)
   c. ProductManifold (formerly the ProductParameterization)

The testing has been completely re-done, where instead of adhoc
testing, we now define a number of matchers which explicitly
enforce the invariants demanded by the Manifold interface.

Change-Id: I3f296d0964388d52b027c99dc86b7730d24d55fa
2021-12-29 17:27:28 -08:00