least-squares-cpp
least-squares-cpp copied to clipboard
Unable to fit normally
Thank you very much for your work I want to iterate out a transformation matrix And with this matrix I can fit the points on a known plane,My constraint is the distance from the point to the plane。But I didn't get the right results 。Can you help me see if the usage is correct

Hi @KAL-AL,
thanks for using least-squares-cpp! So telling from your Objective functor, you should rotate and translate the Points using your translation vector and rotation matrix before you project them on the plane.
So inside your loop you should do something along these lines:
Eigen::Vector3d transformedPoint = rotation * Points->at(i) + translation;
fval(i) = std::abs(Plane->A * transformedPoint(0) + Plane->B * transformedPoint(1) + Plane->C * transformedPoint(2) + Plane->D);
I am assuming that A, B and C define the normal of the plane and D is the offset of the plane from the origin along its normal. Does that do the trick for you?
@KAL-AL Any updates on this?