[Positioning] Point3D: beautify
Use "source" as parameter name for several functions.
This commit is contained in:
parent
1ddebc9cf4
commit
0bce0ad2bd
|
@ -13,19 +13,19 @@ Point3D::Point3D(const float &_x, const float &_y, const float &_z)
|
|||
}
|
||||
|
||||
|
||||
Point3D::Point3D(const Point3D &p)
|
||||
Point3D::Point3D(const Point3D &source)
|
||||
{
|
||||
x = p.x ;
|
||||
y = p.y ;
|
||||
z = p.z ;
|
||||
x = source.x ;
|
||||
y = source.y ;
|
||||
z = source.z ;
|
||||
}
|
||||
|
||||
|
||||
Point3D::Point3D(const float c[3])
|
||||
Point3D::Point3D(const float source[3])
|
||||
{
|
||||
x = c[0] ;
|
||||
y = c[1] ;
|
||||
z = c[2] ;
|
||||
x = source[0] ;
|
||||
y = source[1] ;
|
||||
z = source[2] ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,12 +37,12 @@ Point3D::Point3D(const float c[3])
|
|||
* The distance is not square rooted after the computation, in order
|
||||
* to optimise comparisons.
|
||||
*/
|
||||
float Point3D::square_distance(const Point3D &p) const
|
||||
float Point3D::square_distance(const Point3D &source) const
|
||||
{
|
||||
return
|
||||
(x - p.x) * (x - p.x) +
|
||||
(y - p.y) * (y - p.y) +
|
||||
(z - p.z) * (z - p.z) ;
|
||||
(x - source.x) * (x - source.x) +
|
||||
(y - source.y) * (y - source.y) +
|
||||
(z - source.z) * (z - source.z) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,44 +65,44 @@ float Point3D::square_distance(const float &_x,
|
|||
/* *** Operators *** */
|
||||
|
||||
|
||||
const Point3D& Point3D::operator=(const Point3D &p)
|
||||
const Point3D& Point3D::operator=(const Point3D &source)
|
||||
{
|
||||
if (this == &p)
|
||||
if (this == &source)
|
||||
return *this ;
|
||||
|
||||
x = p.x ;
|
||||
y = p.y ;
|
||||
z = p.z ;
|
||||
x = source.x ;
|
||||
y = source.y ;
|
||||
z = source.z ;
|
||||
|
||||
return *this ;
|
||||
}
|
||||
|
||||
|
||||
bool Point3D::operator==(const Point3D &p) const
|
||||
bool Point3D::operator==(const Point3D &source) const
|
||||
{
|
||||
if (this == &p)
|
||||
if (this == &source)
|
||||
return true ;
|
||||
|
||||
return
|
||||
x == p.x &&
|
||||
y == p.y &&
|
||||
z == p.z ;
|
||||
x == source.x &&
|
||||
y == source.y &&
|
||||
z == source.z ;
|
||||
}
|
||||
|
||||
|
||||
bool Point3D::operator<(const Point3D &p) const
|
||||
bool Point3D::operator<(const Point3D &source) const
|
||||
{
|
||||
if (x < p.x)
|
||||
if (x < source.x)
|
||||
return true ;
|
||||
if (x > p.x)
|
||||
if (x > source.x)
|
||||
return false ;
|
||||
|
||||
if (y < p.y)
|
||||
if (y < source.y)
|
||||
return true ;
|
||||
if (y > p.y)
|
||||
if (y > source.y)
|
||||
return false ;
|
||||
|
||||
if (z < p.z)
|
||||
if (z < source.z)
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
|
|
|
@ -16,9 +16,9 @@ public:
|
|||
/// 3 float constructor or default constructor
|
||||
Point3D(const float &_x = 0, const float &_y = 0, const float &_z = 0) ;
|
||||
/// Copy constructor
|
||||
Point3D(const Point3D &p) ;
|
||||
Point3D(const Point3D &source) ;
|
||||
/// 3-float array constructor
|
||||
Point3D(const float c[3]) ;
|
||||
Point3D(const float source[3]) ;
|
||||
|
||||
virtual ~Point3D(void) {} ///< Destructor (do nothing)
|
||||
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
void set_x(const float &_x) ; ///< #x write accessor
|
||||
void set_y(const float &_y) ; ///< #y write accessor
|
||||
void set_z(const float &_z) ; ///< #z write accessor
|
||||
void set_coordinates(const Point3D &p) ; ///< Sets all coordinates
|
||||
void set_coordinates(const Point3D &source) ; ///< Sets all coordinates
|
||||
//@}
|
||||
|
||||
/** @name Distance operations */
|
||||
|
@ -55,13 +55,13 @@ public:
|
|||
|
||||
/** @name Operators */
|
||||
//@{
|
||||
const Point3D& operator=(const Point3D &p) ;
|
||||
bool operator==(const Point3D &p) const ;
|
||||
bool operator!=(const Point3D &p) const ;
|
||||
bool operator<(const Point3D &p) const ;
|
||||
bool operator>(const Point3D &p) const ;
|
||||
bool operator<=(const Point3D &p) const ;
|
||||
bool operator>=(const Point3D &p) const ;
|
||||
const Point3D& operator=(const Point3D &source) ;
|
||||
bool operator==(const Point3D &source) const ;
|
||||
bool operator!=(const Point3D &source) const ;
|
||||
bool operator<(const Point3D &source) const ;
|
||||
bool operator>(const Point3D &source) const ;
|
||||
bool operator<=(const Point3D &source) const ;
|
||||
bool operator>=(const Point3D &source) const ;
|
||||
//@}
|
||||
|
||||
/// Displays a Point3D
|
||||
|
@ -118,9 +118,9 @@ inline void Point3D::set_z(const float &_z)
|
|||
* This is useful for derivated classes, and different than a direct
|
||||
* call to operator=().
|
||||
*/
|
||||
inline void Point3D::set_coordinates(const Point3D &p)
|
||||
inline void Point3D::set_coordinates(const Point3D &source)
|
||||
{
|
||||
this->operator=(p) ;
|
||||
this->operator=(source) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,9 +132,9 @@ inline void Point3D::set_coordinates(const Point3D &p)
|
|||
* Note: to compare distances, use preferably square_distance(),
|
||||
* which is more efficient.
|
||||
*/
|
||||
inline float Point3D::distance(const Point3D &p) const
|
||||
inline float Point3D::distance(const Point3D &source) const
|
||||
{
|
||||
return sqrt(square_distance(p)) ;
|
||||
return sqrt(square_distance(source)) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,27 +154,27 @@ inline float Point3D::distance(const float &_x,
|
|||
/* *** Operators *** */
|
||||
|
||||
|
||||
inline bool Point3D::operator!=(const Point3D &p) const
|
||||
inline bool Point3D::operator!=(const Point3D &source) const
|
||||
{
|
||||
return !(*this == p) ;
|
||||
return !(*this == source) ;
|
||||
}
|
||||
|
||||
|
||||
inline bool Point3D::operator>(const Point3D &p) const
|
||||
inline bool Point3D::operator>(const Point3D &source) const
|
||||
{
|
||||
return (p < *this) ;
|
||||
return source < *this ;
|
||||
}
|
||||
|
||||
|
||||
inline bool Point3D::operator<=(const Point3D &p) const
|
||||
inline bool Point3D::operator<=(const Point3D &source) const
|
||||
{
|
||||
return (*this < p || *this == p) ;
|
||||
return *this == source || *this < source ;
|
||||
}
|
||||
|
||||
|
||||
inline bool Point3D::operator>=(const Point3D &p) const
|
||||
inline bool Point3D::operator>=(const Point3D &source) const
|
||||
{
|
||||
return (p <= *this) ;
|
||||
return source <= *this ;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue