Skip to content
Permalink
Browse files

better argument names for QgsGeometryUtils::lineIntersection

  • Loading branch information
3nids committed Dec 15, 2017
1 parent 9f99453 commit 978d9277cf98bf857b7f4d03eb91972dfe401d45
@@ -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
@@ -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;
}
@@ -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

0 comments on commit 978d927

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