This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/math/MiniMat2.h
kazu cdf97322f8 added new data-structures
added new test-cases
added flexible dijkstra calculation
added debugging log
modified: plotting, grid-generation, grid-importance,
refactoring
2016-01-22 18:47:06 +01:00

37 lines
621 B
C++

#ifndef MINIMAT2_H
#define MINIMAT2_H
/**
* very simple 2x2 matrix
*/
struct MiniMat2 {
/** store eigenvalues */
struct EV {float e1,e2;};
/** data */
float a,b,c,d;
/** ctor */
MiniMat2() : a(0), b(0), c(0), d(0) {;}
/** get the matrix' eigenvalues */
EV getEigenvalues() const {
const float T = a+d;
const float D = a*d - b*c;
EV res;
res.e1 = T/2 + std::sqrt(T*T/4-D);
res.e2 = T/2 - std::sqrt(T*T/4-D);
return res;
}
/** add (x,y) * (x,y)T to the matrix */
void addSquared(const float x, const float y) {
a += (x*x); b += (x*y);
c += (x*y); d += (y*y);
}
};
#endif // MINIMAT2_H