Skip to content

Commit

Permalink
Added feedback
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <[email protected]>
  • Loading branch information
ahcorde committed Nov 25, 2021
1 parent dc6176a commit 630046a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
13 changes: 7 additions & 6 deletions include/ignition/math/Vector2.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define IGNITION_MATH_VECTOR2_HH_

#include <algorithm>
#include <cmath>
#include <limits>

#include <ignition/math/Helpers.hh>
Expand Down Expand Up @@ -106,12 +107,12 @@ namespace ignition
/// \brief Normalize the vector length
public: void Normalize()
{
double d = this->Length();
T d = this->Length();

if (!equal<T>(static_cast<T>(d), static_cast<T>(0.0)))
if (!equal<T>(d, static_cast<T>(0.0)))
{
this->data[0] /= static_cast<T>(d);
this->data[1] /= static_cast<T>(d);
this->data[0] /= d;
this->data[1] /= d;
}
}

Expand All @@ -128,8 +129,8 @@ namespace ignition
/// \return the result
public: Vector2 Round()
{
this->data[0] = static_cast<T>(nearbyint(this->data[0]));
this->data[1] = static_cast<T>(nearbyint(this->data[1]));
this->data[0] = std::nearbyint(this->data[0]);
this->data[1] = std::nearbyint(this->data[1]);
return *this;
}

Expand Down
6 changes: 3 additions & 3 deletions include/ignition/math/Vector3.hh
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ namespace ignition
/// \return the result
public: Vector3 Round()
{
this->data[0] = static_cast<T>(nearbyint(this->data[0]));
this->data[1] = static_cast<T>(nearbyint(this->data[1]));
this->data[2] = static_cast<T>(nearbyint(this->data[2]));
this->data[0] = std::nearbyint(this->data[0]);
this->data[1] = std::nearbyint(this->data[1]);
this->data[2] = std::nearbyint(this->data[2]);
return *this;
}

Expand Down
9 changes: 5 additions & 4 deletions include/ignition/math/Vector4.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define IGNITION_MATH_VECTOR4_HH_

#include <algorithm>
#include <cmath>
#include <limits>

#include <ignition/math/Matrix4.hh>
Expand Down Expand Up @@ -121,10 +122,10 @@ namespace ignition
/// \brief Round to near whole number.
public: void Round()
{
this->data[0] = static_cast<T>(nearbyint(this->data[0]));
this->data[1] = static_cast<T>(nearbyint(this->data[1]));
this->data[2] = static_cast<T>(nearbyint(this->data[2]));
this->data[3] = static_cast<T>(nearbyint(this->data[3]));
this->data[0] = std::nearbyint(this->data[0]);
this->data[1] = std::nearbyint(this->data[1]);
this->data[2] = std::nearbyint(this->data[2]);
this->data[3] = std::nearbyint(this->data[3]);
}

/// \brief Get a rounded version of this vector
Expand Down

0 comments on commit 630046a

Please sign in to comment.