@@ -48,8 +48,8 @@ namespace gz::math
4848 // / \param[in] _y1 Y coordinate of the start point.
4949 // / \param[in] _x2 X coordinate of the end point.
5050 // / \param[in] _y2 Y coordinate of the end point.
51- public: Line3(const double _x1, const double _y1,
52- const double _x2, const double _y2)
51+ public: Line3(const T _x1, const T _y1,
52+ const T _x2, const T _y2)
5353 {
5454 this ->Set (_x1, _y1, _x2, _y2);
5555 }
@@ -61,9 +61,9 @@ namespace gz::math
6161 // / \param[in] _x2 X coordinate of the end point.
6262 // / \param[in] _y2 Y coordinate of the end point.
6363 // / \param[in] _z2 Z coordinate of the end point.
64- public: Line3(const double _x1, const double _y1,
65- const double _z1, const double _x2,
66- const double _y2, const double _z2)
64+ public: Line3(const T _x1, const T _y1,
65+ const T _z1, const T _x2,
66+ const T _y2, const T _z2)
6767 {
6868 this ->Set (_x1, _y1, _z1, _x2, _y2, _z2);
6969 }
@@ -100,9 +100,9 @@ namespace gz::math
100100 // / \param[in] _y2 Y coordinate of the end point.
101101 // / \param[in] _z Z coordinate of both points,
102102 // / by default _z is set to 0.
103- public: void Set (const double _x1, const double _y1,
104- const double _x2, const double _y2,
105- const double _z = 0 )
103+ public: void Set (const T _x1, const T _y1,
104+ const T _x2, const T _y2,
105+ const T _z = 0 )
106106 {
107107 this ->pts [0 ].Set (_x1, _y1, _z);
108108 this ->pts [1 ].Set (_x2, _y2, _z);
@@ -115,9 +115,9 @@ namespace gz::math
115115 // / \param[in] _x2 X coordinate of the end point.
116116 // / \param[in] _y2 Y coordinate of the end point.
117117 // / \param[in] _z2 Z coordinate of the end point.
118- public: void Set (const double _x1, const double _y1,
119- const double _z1, const double _x2,
120- const double _y2, const double _z2)
118+ public: void Set (const T _x1, const T _y1,
119+ const T _z1, const T _x2,
120+ const T _y2, const T _z2)
121121 {
122122 this ->pts [0 ].Set (_x1, _y1, _z1);
123123 this ->pts [1 ].Set (_x2, _y2, _z2);
@@ -134,7 +134,7 @@ namespace gz::math
134134 // / \return The length of the line.
135135 public: T Length () const
136136 {
137- return this ->pts [0 ].Distance (this ->pts [1 ]);
137+ return static_cast <T>( this ->pts [0 ].Distance (this ->pts [1 ]) );
138138 }
139139
140140 // / \brief Get the shortest line between this line and the
@@ -214,7 +214,8 @@ namespace gz::math
214214 double mua = clamp (numer / denom, 0.0 , 1.0 );
215215 double mub = clamp ((d1343 + d4321 * mua) / d4343, 0.0 , 1.0 );
216216
217- _result.Set (this ->pts [0 ] + (p21 * mua), _line[0 ] + (p43 * mub));
217+ _result.Set (this ->pts [0 ] + (p21 * static_cast <T>(mua)),
218+ _line[0 ] + (p43 * static_cast <T>(mub)));
218219
219220 return true ;
220221 }
@@ -229,13 +230,13 @@ namespace gz::math
229230 auto ptTo1 = _pt - this ->pts [1 ];
230231
231232 // Point is projected beyond pt0 or the line has length 0
232- if (ptTo0.Dot (line) <= 0.0 )
233+ if (ptTo0.Dot (line) <= static_cast <T>( 0 ) )
233234 {
234235 return ptTo0.Length ();
235236 }
236237
237238 // Point is projected beyond pt1
238- if (ptTo1.Dot (line) >= 0.0 )
239+ if (ptTo1.Dot (line) >= static_cast <T>( 0 ) )
239240 {
240241 return ptTo1.Length ();
241242 }
@@ -341,18 +342,19 @@ namespace gz::math
341342 public: bool Within (const math::Vector3<T> &_pt,
342343 double _epsilon = 1e-6 ) const
343344 {
345+ auto eps = static_cast <T>(_epsilon);
344346 return _pt.X () <= std::max (this ->pts [0 ].X (),
345- this ->pts [1 ].X ()) + _epsilon &&
347+ this ->pts [1 ].X ()) + eps &&
346348 _pt.X () >= std::min (this ->pts [0 ].X (),
347- this ->pts [1 ].X ()) - _epsilon &&
349+ this ->pts [1 ].X ()) - eps &&
348350 _pt.Y () <= std::max (this ->pts [0 ].Y (),
349- this ->pts [1 ].Y ()) + _epsilon &&
351+ this ->pts [1 ].Y ()) + eps &&
350352 _pt.Y () >= std::min (this ->pts [0 ].Y (),
351- this ->pts [1 ].Y ()) - _epsilon &&
353+ this ->pts [1 ].Y ()) - eps &&
352354 _pt.Z () <= std::max (this ->pts [0 ].Z (),
353- this ->pts [1 ].Z ()) + _epsilon &&
355+ this ->pts [1 ].Z ()) + eps &&
354356 _pt.Z () >= std::min (this ->pts [0 ].Z (),
355- this ->pts [1 ].Z ()) - _epsilon ;
357+ this ->pts [1 ].Z ()) - eps ;
356358 }
357359
358360 // / \brief Equality operator.
0 commit comments