{{ message }}

qgis / QGIS Public

Add API to calculate innerTangents for 2 circles
raymondnijssen authored and nyalldawson committed Jan 13, 2019
1 parent aafd848 commit 0ba9a326ec77bb67a1bcae61de21a9cbcafee660
 @@ -188,6 +188,31 @@ Note that this method is 2D only and does not consider the z-value of the circle .. seealso:: :py:func:`tangentToPoint` .. versionadded:: 3.2 %End int innerTangents( const QgsCircle &other, QgsPointXY &line1P1 /Out/, QgsPointXY &line1P2 /Out/, QgsPointXY &line2P1 /Out/, QgsPointXY &line2P2 /Out/ ) const; %Docstring Calculates the inner tangent points between this circle and an ``other`` circle. The inner tangent points correspond to the points at which the two lines which are drawn so that they are tangential to both circles but on different sides, touching the circles and crossing each other. The first tangent line is described by the points stored in ``line1P1`` and ``line1P2``, and the second line is described by the points stored in ``line2P1`` and ``line2P2``. Returns the number of tangents (either 0 or 2). Note that this method is 2D only and does not consider the z-value of the circle. .. seealso:: :py:func:`tangentToPoint` .. versionadded:: 3.6 %End virtual double area() const;
 @@ -202,6 +202,29 @@ and ``line2P2``. Returns the number of tangents (either 0 or 2). .. versionadded:: 3.2 %End static int circleCircleInnerTangents( const QgsPointXY ¢er1, double radius1, const QgsPointXY ¢er2, double radius2, QgsPointXY &line1P1 /Out/, QgsPointXY &line1P2 /Out/, QgsPointXY &line2P1 /Out/, QgsPointXY &line2P2 /Out/ ); %Docstring Calculates the inner tangent points for two circles, centered at \a center1 and ``center2`` and with radii of ``radius1`` and ``radius2`` respectively. The inner tangent points correspond to the points at which the two lines which are drawn so that they are tangential to both circles and are crossing each other. The first tangent line is described by the points stored in ``line1P1`` and ``line1P2``, and the second line is described by the points stored in ``line2P1`` and ``line2P2``. Returns the number of tangents (either 0 or 2). .. versionadded:: 3.6 %End static QgsPoint projectPointOnSegment( const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2 );
 @@ -270,6 +270,12 @@ int QgsCircle::outerTangents( const QgsCircle &other, QgsPointXY &line1P1, QgsPo QgsPointXY( other.center() ), other.radius(), line1P1, line1P2, line2P1, line2P2 ); } int QgsCircle::innerTangents( const QgsCircle &other, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2 ) const { return QgsGeometryUtils::circleCircleInnerTangents( QgsPointXY( mCenter ), radius(), QgsPointXY( other.center() ), other.radius(), line1P1, line1P2, line2P1, line2P2 ); } QgsCircle QgsCircle::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) { double delta_x = std::fabs( pt1.x() - pt2.x() );
 @@ -166,7 +166,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse * \returns true if tangent was found. * * * \see outerTangents() * \see outerTangents() and innerTangents() * \since QGIS 3.2 */ bool tangentToPoint( const QgsPointXY &p, QgsPointXY &pt1 SIP_OUT, QgsPointXY &pt2 SIP_OUT ) const; @@ -189,13 +189,38 @@ class CORE_EXPORT QgsCircle : public QgsEllipse * Note that this method is 2D only and does not consider the z-value of the circle. * * * \see tangentToPoint() * \see tangentToPoint() and innerTangents() * \since QGIS 3.2 */ int outerTangents( const QgsCircle &other, QgsPointXY &line1P1 SIP_OUT, QgsPointXY &line1P2 SIP_OUT, QgsPointXY &line2P1 SIP_OUT, QgsPointXY &line2P2 SIP_OUT ) const; /** * Calculates the inner tangent points between this circle * and an \a other circle. * * The inner tangent points correspond to the points at which the two lines * which are drawn so that they are tangential to both circles but on * different sides, touching the circles and crossing each other. * * The first tangent line is described by the points * stored in \a line1P1 and \a line1P2, * and the second line is described by the points stored in \a line2P1 * and \a line2P2. * * Returns the number of tangents (either 0 or 2). * * Note that this method is 2D only and does not consider the z-value of the circle. * * * \see tangentToPoint() and outerTangents() * \since QGIS 3.6 */ int innerTangents( const QgsCircle &other, QgsPointXY &line1P1 SIP_OUT, QgsPointXY &line1P2 SIP_OUT, QgsPointXY &line2P1 SIP_OUT, QgsPointXY &line2P2 SIP_OUT ) const; double area() const override; double perimeter() const override;