Edge3Factor.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Created by zx on 23-6-20.
  3. //
  4. #include "Edge3Factor.h"
  5. Vector Edge3Factor::evaluateError(const double& x, const double& y, const double& z,
  6. boost::optional<Matrix&> H1,
  7. boost::optional<Matrix&> H2,
  8. boost::optional<Matrix&> H3) const {
  9. if (H1) {
  10. *H1 = (Matrix(2, 1) << (z - pb_ * y) / (x * x), pa_ / y).finished();
  11. }
  12. if (H2) {
  13. *H2 = (Matrix(2, 1) << pb_/x, (z-pa_*x)/(y*y)).finished();
  14. }
  15. if (H3) {
  16. *H3 = (Matrix(2, 1) << -1.0/x, -1.0 / y).finished();
  17. }
  18. return (Vector(2)<<pa_-(z-pb_*y)/x,pb_-(z-pa_*x)/y).finished();
  19. }
  20. Vector Edge3Factor2::evaluateError(const double& x, const double& y, const double& z,
  21. boost::optional<Matrix&> H1,
  22. boost::optional<Matrix&> H2,
  23. boost::optional<Matrix&> H3) const {
  24. if (H1) {
  25. *H1 = (Matrix(2, 1) << (z - pb_ * y) / (x * x), pa_ / y).finished();
  26. }
  27. if (H2) {
  28. *H2 = (Matrix(2, 1) << pb_/x, (z-pa_*x)/(y*y)).finished();
  29. }
  30. if (H3) {
  31. *H3 = (Matrix(2, 1) << -1.0/x, -1.0 / y).finished();
  32. }
  33. return (Vector(2)<<pa_-(z-pb_*y)/x,pb_-(z-pa_*x)/y).finished();
  34. }