Skip to content
Permalink
Browse files

remove distanceFromPoint

  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Jan 13, 2021
1 parent 4e2133f commit 0073c35b6562ef480e25b8f98c42bb45df120c92
@@ -217,13 +217,6 @@ Returns ``True`` when box contains a ``point``.

If the point is a 2D point (no z-coordinate), then the containment test
will be performed on the x/y extent of the box only.
%End

float distanceFromPoint( double x, double y, double z ) const;
%Docstring
Returns shortest distance from the box to a point (returns 0 if the point is inside the box)

.. versionadded:: 3.18
%End

QgsRectangle toRectangle() const;
@@ -124,11 +124,3 @@ bool QgsBox3d::operator==( const QgsBox3d &other ) const
qgsDoubleNear( mZmin, other.mZmin ) &&
qgsDoubleNear( mZmax, other.mZmax );
}

float QgsBox3d::distanceFromPoint( double x, double y, double z ) const
{
float dx = std::max( mBounds2d.xMinimum() - x, std::max( 0., x - mBounds2d.xMaximum() ) );
float dy = std::max( mBounds2d.yMinimum() - y, std::max( 0., y - mBounds2d.yMaximum() ) );
float dz = std::max( mZmin - z, std::max( 0., z - mZmax ) );
return sqrt( dx * dx + dy * dy + dz * dz );
}
@@ -198,12 +198,6 @@ class CORE_EXPORT QgsBox3d
*/
bool contains( const QgsPoint &point ) const;

/**
* Returns shortest distance from the box to a point (returns 0 if the point is inside the box)
* \since QGIS 3.18
*/
float distanceFromPoint( double x, double y, double z ) const;

/**
* Converts the box to a 2D rectangle.
*/
@@ -81,8 +81,8 @@ double QgsRay3D::angleToPoint( const QVector3D &point ) const

double QgsRay3D::distanceTo( const QgsBox3d &box ) const
{
float dx = std::max( box.xMinimum() - mOrigin.x(), std::max( 0., mOrigin.x() - box.xMaximum() ) );
float dy = std::max( box.yMinimum() - mOrigin.y(), std::max( 0., mOrigin.y() - box.yMaximum() ) );
float dz = std::max( box.zMinimum() - mOrigin.z(), std::max( 0., mOrigin.z() - box.zMaximum() ) );
double dx = std::max( box.xMinimum() - mOrigin.x(), std::max( 0., mOrigin.x() - box.xMaximum() ) );
double dy = std::max( box.yMinimum() - mOrigin.y(), std::max( 0., mOrigin.y() - box.yMaximum() ) );
double dz = std::max( box.zMinimum() - mOrigin.z(), std::max( 0., mOrigin.z() - box.zMaximum() ) );
return sqrt( dx * dx + dy * dy + dz * dz );
}

0 comments on commit 0073c35

Please sign in to comment.
You can’t perform that action at this time.