worked on 3d models within map
adjusted grid factory adjusted nav mesh factory minoor changes/fixes new helper classes refactoring
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "../../Assertions.h"
|
||||
#include "../random/RandomGenerator.h"
|
||||
#include "../../geo/Point2.h"
|
||||
#include "ChiSquared.h"
|
||||
|
||||
namespace Distribution {
|
||||
|
||||
@@ -96,6 +98,43 @@ namespace Distribution {
|
||||
return NormalDistributionN(mean, cov);
|
||||
}
|
||||
|
||||
std::vector<Point2> getContour2(const double percentWithin) {
|
||||
|
||||
const int degreesOfFreedom = 2; // 2D distribution
|
||||
const ChiSquared<double> chi(degreesOfFreedom);
|
||||
|
||||
// https://people.richland.edu/james/lecture/m170/tbl-chi.html
|
||||
Assert::isNear(0.103, chi.getInvCDF(0.05), 0.01, "error within chi-squared distribution");
|
||||
Assert::isNear(0.211, chi.getInvCDF(0.10), 0.01, "error within chi-squared distribution");
|
||||
Assert::isNear(4.605, chi.getInvCDF(0.90), 0.01, "error within chi-squared distribution");
|
||||
Assert::isNear(5.991, chi.getInvCDF(0.95), 0.03, "error within chi-squared distribution");
|
||||
|
||||
// size of the ellipse using confidence intervals
|
||||
const float mul = chi.getInvCDF(percentWithin);
|
||||
|
||||
std::vector<Point2> res;
|
||||
|
||||
std::cout << sigma << std::endl;
|
||||
Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> solver(this->sigma);
|
||||
|
||||
Eigen::Vector2d evec1 = solver.eigenvectors().col(0);
|
||||
Eigen::Vector2d evec2 = solver.eigenvectors().col(1);
|
||||
|
||||
double eval1 = solver.eigenvalues()(0);
|
||||
double eval2 = solver.eigenvalues()(1);
|
||||
|
||||
for (int deg = 0; deg <= 360; deg += 5) {
|
||||
const float rad = deg / 180.0f * M_PI;
|
||||
Eigen::Vector2d pos =
|
||||
std::cos(rad) * std::sqrt(mul * eval1) * evec1 +
|
||||
std::sin(rad) * std::sqrt(mul * eval2) * evec2;
|
||||
res.push_back(Point2(pos(0), pos(1)));
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user