Skip to content

Commit

Permalink
better argument names for QgsGeometryUtils::lineIntersection
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Dec 15, 2017
1 parent 9f99453 commit 978d927
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions python/core/geometry/qgsgeometryutils.sip
Expand Up @@ -99,14 +99,14 @@ Returns the squared distance between a point and a line.
:rtype: float
%End

static bool lineIntersection( const QgsPoint &p1, QgsVector v, const QgsPoint &q1, QgsVector w, QgsPoint &inter /Out/ );
static bool lineIntersection( const QgsPoint &p1, QgsVector v1, const QgsPoint &p2, QgsVector v2, QgsPoint &intersection /Out/ );
%Docstring
Compute the intersection between two lines
:param p1: Point on the first line
:param v: Direction vector of the first line
:param q1: Point on the second line
:param w: Direction vector of the second line
:param inter: Output parameter, the intersection point
:param v1: Direction vector of the first line
:param p2: Point on the second line
:param v2: Direction vector of the second line
:param intersection: Output parameter, the intersection point

:return: Whether the lines intersect
:rtype: bool
Expand Down
12 changes: 6 additions & 6 deletions src/core/geometry/qgsgeometryutils.cpp
Expand Up @@ -235,18 +235,18 @@ double QgsGeometryUtils::sqrDistToLine( double ptX, double ptY, double x1, doubl
return dist;
}

bool QgsGeometryUtils::lineIntersection( const QgsPoint &p1, QgsVector v, const QgsPoint &q1, QgsVector w, QgsPoint &inter )
bool QgsGeometryUtils::lineIntersection( const QgsPoint &p1, QgsVector v1, const QgsPoint &p2, QgsVector v2, QgsPoint &intersection )
{
double d = v.y() * w.x() - v.x() * w.y();
double d = v1.y() * v2.x() - v1.x() * v2.y();

if ( qgsDoubleNear( d, 0 ) )
return false;

double dx = q1.x() - p1.x();
double dy = q1.y() - p1.y();
double k = ( dy * w.x() - dx * w.y() ) / d;
double dx = p2.x() - p1.x();
double dy = p2.y() - p1.y();
double k = ( dy * v2.x() - dx * v2.y() ) / d;

inter = QgsPoint( p1.x() + v.x() * k, p1.y() + v.y() * k );
intersection = QgsPoint( p1.x() + v1.x() * k, p1.y() + v1.y() * k );

return true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/geometry/qgsgeometryutils.h
Expand Up @@ -92,13 +92,13 @@ class CORE_EXPORT QgsGeometryUtils
/**
* \brief Compute the intersection between two lines
* \param p1 Point on the first line
* \param v Direction vector of the first line
* \param q1 Point on the second line
* \param w Direction vector of the second line
* \param inter Output parameter, the intersection point
* \param v1 Direction vector of the first line
* \param p2 Point on the second line
* \param v2 Direction vector of the second line
* \param intersection Output parameter, the intersection point
* \returns Whether the lines intersect
*/
static bool lineIntersection( const QgsPoint &p1, QgsVector v, const QgsPoint &q1, QgsVector w, QgsPoint &inter SIP_OUT );
static bool lineIntersection( const QgsPoint &p1, QgsVector v1, const QgsPoint &p2, QgsVector v2, QgsPoint &intersection SIP_OUT );

/**
* \brief Compute the intersection between two segments
Expand Down

0 comments on commit 978d927

Please sign in to comment.