Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
Remove duplication from distort methods
Browse files Browse the repository at this point in the history
Signed-off-by: Audrow Nash <audrow@hey.com>
  • Loading branch information
paudrow committed Jun 11, 2021
1 parent 774bab3 commit 4fe9c4b
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions gazebo/rendering/Distortion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,27 +470,7 @@ ignition::math::Vector2d Distortion::Distort(
const ignition::math::Vector2d &_center, double _k1, double _k2, double _k3,
double _p1, double _p2)
{
// apply Brown's distortion model, see
// http://en.wikipedia.org/wiki/Distortion_%28optics%29#Software_correction

ignition::math::Vector2d normalized2d = _in - _center;
ignition::math::Vector3d normalized(normalized2d.X(), normalized2d.Y(), 0);
double rSq = normalized.X() * normalized.X() +
normalized.Y() * normalized.Y();

// radial
ignition::math::Vector3d dist = normalized * (1.0 +
_k1 * rSq +
_k2 * rSq * rSq +
_k3 * rSq * rSq * rSq);

// tangential
dist.X() += _p2 * (rSq + 2 * (normalized.X()*normalized.X())) +
2 * _p1 * normalized.X() * normalized.Y();
dist.Y() += _p1 * (rSq + 2 * (normalized.Y()*normalized.Y())) +
2 * _p2 * normalized.X() * normalized.Y();

return _center + ignition::math::Vector2d(dist.X(), dist.Y());
return Distort(_in, _center, _k1, _k2, _k3, _p1, _p2, 1u, 1.0);
}

//////////////////////////////////////////////////
Expand Down

0 comments on commit 4fe9c4b

Please sign in to comment.