Skip to content

Commit 84266d7

Browse files
authored
Fix type conversion warnings
* Set: use static_cast<T> * Length: use simpler approach from Line3::Length Signed-off-by: Steve Peters <scpeters@intrinsic.ai>
1 parent 70aac2d commit 84266d7

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

include/gz/math/Line2.hh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ namespace gz::math
6767
/// \param[in] _y2 Y coordinate of the end point.
6868
public: void Set(double _x1, double _y1, double _x2, double _y2)
6969
{
70-
this->pts[0].Set(_x1, _y1);
71-
this->pts[1].Set(_x2, _y2);
70+
this->pts[0].Set(static_cast<T>(_x1), static_cast<T>(_y1));
71+
this->pts[1].Set(static_cast<T>(_x2), static_cast<T>(_y2));
7272
}
7373

7474
/// \brief Return the cross product of this line and the given line.
@@ -253,10 +253,7 @@ namespace gz::math
253253
/// \return The length of the line.
254254
public: T Length() const
255255
{
256-
return sqrt((this->pts[0].X() - this->pts[1].X()) *
257-
(this->pts[0].X() - this->pts[1].X()) +
258-
(this->pts[0].Y() - this->pts[1].Y()) *
259-
(this->pts[0].Y() - this->pts[1].Y()));
256+
return this->pts[0].Distance(this->pts[1]);
260257
}
261258

262259
/// \brief Get the slope of the line

0 commit comments

Comments
 (0)