Skip to content
Snippets Groups Projects
Commit 9053dd97 authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

add the distance function and its derivatives to Rotation<2>

[[Imported from SVN: r5784]]
parent 11db41d0
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,10 @@ public: ...@@ -33,6 +33,10 @@ public:
: angle_(0) : angle_(0)
{} {}
Rotation(const T& angle)
: angle_(angle)
{}
/** \brief Return the identity element */ /** \brief Return the identity element */
static Rotation<2,T> identity() { static Rotation<2,T> identity() {
// Default constructor creates an identity // Default constructor creates an identity
...@@ -40,6 +44,16 @@ public: ...@@ -40,6 +44,16 @@ public:
return id; return id;
} }
static T distance(const Rotation<2,T>& a, const Rotation<2,T>& b) {
T dist = a.angle_ - b.angle_;
while (dist < 0)
dist += 2*M_PI;
while (dist > 2*M_PI)
dist -= 2*M_PI;
return (dist <= M_PI) ? dist : 2*M_PI - dist;
}
/** \brief The exponential map from a given point $p \in SO(3)$. */ /** \brief The exponential map from a given point $p \in SO(3)$. */
static Rotation<2,T> exp(const Rotation<2,T>& p, const TangentVector& v) { static Rotation<2,T> exp(const Rotation<2,T>& p, const TangentVector& v) {
Rotation<2,T> result = p; Rotation<2,T> result = p;
...@@ -55,6 +69,16 @@ public: ...@@ -55,6 +69,16 @@ public:
return result; return result;
} }
static TangentVector derivativeOfDistanceSquaredWRTSecondArgument(const Rotation<2,T>& a,
const Rotation<2,T>& b) {
return -2 * distance(a,b);
}
static TangentVector secondDerivativeOfDistanceSquaredWRTSecondArgument(const Rotation<2,T>& a,
const Rotation<2,T>& b) {
return 2;
}
/** \brief Right multiplication */ /** \brief Right multiplication */
Rotation<2,T> mult(const Rotation<2,T>& other) const { Rotation<2,T> mult(const Rotation<2,T>& other) const {
Rotation<2,T> q = *this; Rotation<2,T> q = *this;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment