Skip to content

Chapter 5 - Improvement For Line and Plane Fitting #192

Description

@RicoJia

"我们使用快速的 SVD 分解,仅计算 A 矩阵 SVD 结果的最后一列。"....

This is used in both line and plane fitting. For example, the code is here

Eigen::JacobiSVD svd(A, Eigen::ComputeThinV);
plane_coeffs = svd.matrixV().col(3);

On my machine, it turns out that Eigen::SelfAdjointEigenSolver is 2x faster, possibly because it only operates on an nxn symmetric matrices, whereas SVD works on mxn general matrices:

  Eigen::MatrixXf ATA = A.transpose() * A;   // Compute A^T A

  Eigen::SelfAdjointEigenSolver<Eigen::MatrixXf> solver(ATA);   // Efficient for symmetric matrices

  if (solver.info() != Eigen::Success) {
      throw std::runtime_error("Eigen decomposition failed!");
  }

  return {solver.eigenvalues(), solver.eigenvectors()};

I understand that it's the method that the book uses, so I'm happy to leave this as a comment instead of a PR. Well, please feel free to close if this makes sense 😊 @gaoxiang12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions