Note: I'm probably doing something that isn't supposed to be & my eigen knowledge is pretty limited but couldn't find what I look for.
I'm currently using eigen to get the direction vector of a pointcloud line.
//Compute eigenvalues and eigenvectors:
Eigen::SelfAdjointEigenSolver<Eigen::MatrixXf> eig(scatter);
Eigen::MatrixXf eigvecs = eig.eigenvectors();
//largest eigenvalue is yeild at its last column
b->x = eigvecs(0, 2);
b->y = eigvecs(1, 2);
b->z = eigvecs(2, 2);
with "b" being a pointer on a structure defined as:
typedef struct
{
double x;
double y;
double z;
}3d_point;
using this "scatter" input:
80.0156 5.29252 2.06179
5.29252 0.489233 0.214055
2.06179 0.214055 3.17522
eigein output b (which is the direction vector of the line) :
b = (0.997452, 0.06653, 0.0268062)
I get that a direction vector with a norm equal to 1 is enough. But as I know the "global" start point of this line, I was hopping to use "b" to get the global end point, thus the length of that line.
Is there any way to get the not normed b-vector ?
================
Following the answer I'm currently at that point:
Eigen::Vector3d meanV ;
meanV << a->x, a->y, a->z; //a is a 3d_point struct
points.rowwise() -= meanV.transpose(); // with Eigen::MatrixXd points = Eigen::MatrixXd::Zero(700, 3);
and this obviously fails as dimension do not matches:
Eigen::VectorXd projected = eigvecs.col(2).transpose() * points;
What did I misunderstood in your answer?