mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 16:40:38 +08:00
Added a simplified robotics example for DynamicAutoDiffCostFunction.
Change-Id: I9520e0a9a8d9743285c5114523fbafa6ffa5b0bd
This commit is contained in:
+1
-19
@@ -37,6 +37,7 @@
|
||||
#include "Eigen/Core"
|
||||
#include "ceres/rotation.h"
|
||||
#include "glog/logging.h"
|
||||
#include "random.h"
|
||||
|
||||
namespace ceres {
|
||||
namespace examples {
|
||||
@@ -44,25 +45,6 @@ namespace {
|
||||
typedef Eigen::Map<Eigen::VectorXd> VectorRef;
|
||||
typedef Eigen::Map<const Eigen::VectorXd> ConstVectorRef;
|
||||
|
||||
inline double RandDouble() {
|
||||
double r = static_cast<double>(rand());
|
||||
return r / RAND_MAX;
|
||||
}
|
||||
|
||||
// Box-Muller algorithm for normal random number generation.
|
||||
// http://en.wikipedia.org/wiki/Box-Muller_transform
|
||||
inline double RandNormal() {
|
||||
double x1, x2, w;
|
||||
do {
|
||||
x1 = 2.0 * RandDouble() - 1.0;
|
||||
x2 = 2.0 * RandDouble() - 1.0;
|
||||
w = x1 * x1 + x2 * x2;
|
||||
} while ( w >= 1.0 || w == 0.0 );
|
||||
|
||||
w = sqrt((-2.0 * log(w)) / w);
|
||||
return x1 * w;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void FscanfOrDie(FILE* fptr, const char* format, T* value) {
|
||||
int num_scanned = fscanf(fptr, format, value);
|
||||
|
||||
Reference in New Issue
Block a user