Skip to content

Commit

Permalink
Merge pull request #175 from DUNE/kalman-direction-fix
Browse files Browse the repository at this point in the history
Fixed grossly wrong vector transformation in Kalman Set...Direction
  • Loading branch information
LiamOS authored Oct 22, 2024
2 parents 47bb14e + 0b9c3d2 commit 7a4c306
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/TMS_Kalman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,32 @@ TVectorD TMS_Kalman::GetNoiseVector(TMS_KalmanNode Node) {

return toy;
}


void TMS_Kalman::SetStartDirection(double ax, double ay)
{
// Defining a vector by two slopes is a bit odd;
// it's not possible to define vectors in the x/y plane for example.
// Consider the dector (dx/dz, dy/dz, dz/dz), the z component is 1 by construction,
// and thus we normalise this
double mag = sqrt(ax*ax + ay*ay + 1);
double mag2 = ax*ax + ay*ay + 1; // square of mag

StartDirection[0]=ax/mag;
StartDirection[1]=ay/mag;
StartDirection[2]=sqrt(1 - ax*ax/mag2 - ay*ay/mag2);
}

void TMS_Kalman::SetEndDirection(double ax, double ay)
{
// Defining a vector by two slopes is a bit odd;
// it's not possible to define vectors in the x/y plane for example.
// Consider the dector (dx/dz, dy/dz, dz/dz), the z component is 1 by construction,
// and thus we normalise this
double mag = sqrt(ax*ax + ay*ay + 1);
double mag2 = ax*ax + ay*ay + 1; // square of mag

StartDirection[0]=ax/mag;
StartDirection[1]=ay/mag;
StartDirection[2]=sqrt(1 - ax*ax/mag2 - ay*ay/mag2);
}
4 changes: 2 additions & 2 deletions src/TMS_Kalman.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ class TMS_Kalman {

void SetMomentum(double mom) {momentum = mom;}
// Set direction unit vectors from only x and y slope
void SetStartDirection(double ax, double ay) {StartDirection[0]=ax; StartDirection[1]=ay; StartDirection[2]=sqrt(1 - ax*ax - ay*ay);};
void SetEndDirection (double ax, double ay) {EndDirection[0]=ax; EndDirection[1]=ay; EndDirection[2]=sqrt(1 - ax*ax - ay*ay);};
void SetStartDirection(double ax, double ay);// {StartDirection[0]=ax; StartDirection[1]=ay; StartDirection[2]=sqrt(1 - ax*ax - ay*ay);};
void SetEndDirection (double ax, double ay);// {EndDirection[0]=ax; EndDirection[1]=ay; EndDirection[2]=sqrt(1 - ax*ax - ay*ay);};

// Set position unit vectors
void SetStartPosition(double ax, double ay, double az) {Start[0]=ax; Start[1]=ay; Start[2]=az;};
Expand Down

0 comments on commit 7a4c306

Please sign in to comment.