File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
src/RaidZeroLib/api/Geometry Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -101,21 +101,21 @@ bool Pose::isApprox(const Pose& rhs) const noexcept {
101101}
102102
103103au::QuantityD<au::Inverse<au::Meters>> curvatureToPoint (const Pose& pose, const Point& point) noexcept {
104- const double a = -au::tan (pose.Theta ());
105- const double b = 1 ;
106- const auto c = au::tan (pose.Theta ()) * pose.X () - pose.Y ();
107-
108- const auto x = au::abs (point.X () * a + point.Y () * b + c) / au::sqrt (a * a + b * b);
109- const au::QuantityD<au::Meters> sideL =
110- au::sin (pose.Theta ()) * (point.X () - pose.X ()) - cos (pose.Theta ()) * (point.Y () - pose.Y ());
104+ const auto dx = point.X () - pose.X ();
105+ const auto dy = point.Y () - pose.Y ();
106+ const auto sideL = sin (pose.Theta ()) * dx - cos (pose.Theta ()) * dy;
111107
112108 if (sideL == au::ZERO){
113109 return au::ZERO;
114110 }
115111
116- const double side = sideL / au::abs (sideL);
117- const au::QuantityD<au::Meters> chord = pose.getPoint ().distTo (point);
112+ const auto chord = pose.getPoint ().distTo (point);
113+ if (chord == au::ZERO){
114+ return au::ZERO;
115+ }
118116
117+ const auto x = abs (sideL);
118+ const auto side = sideL / abs (sideL);
119119 return (2 * x) / (chord * chord) * side;
120120}
121121
You can’t perform that action at this time.
0 commit comments