QgsTriangle QgsRegularPolygon::toTriangle() const { if ( isEmpty() || ( mNumberSides != 3 ) ) { return QgsTriangle(); } QgsPointSequence pts; pts = points(); return QgsTriangle( pts.at( 0 ), pts.at( 1 ), pts.at( 2 ) ); }
QgsTriangle QgsTriangle::medial() const { QgsPoint p1, p2, p3; p1 = QgsGeometryUtils::midpoint( vertexAt( 0 ), vertexAt( 1 ) ); p2 = QgsGeometryUtils::midpoint( vertexAt( 1 ), vertexAt( 2 ) ); p3 = QgsGeometryUtils::midpoint( vertexAt( 2 ), vertexAt( 0 ) ); return QgsTriangle( p1, p2, p3 ); }
QgsCircle QgsCircle::from3Tangents( const QgsPoint &pt1_tg1, const QgsPoint &pt2_tg1, const QgsPoint &pt1_tg2, const QgsPoint &pt2_tg2, const QgsPoint &pt1_tg3, const QgsPoint &pt2_tg3, double epsilon ) { QgsPoint p1, p2, p3; QgsGeometryUtils::segmentIntersection( pt1_tg1, pt2_tg1, pt1_tg2, pt2_tg2, p1, epsilon ); QgsGeometryUtils::segmentIntersection( pt1_tg1, pt2_tg1, pt1_tg3, pt2_tg3, p2, epsilon ); QgsGeometryUtils::segmentIntersection( pt1_tg2, pt2_tg2, pt1_tg3, pt2_tg3, p3, epsilon ); return QgsTriangle( p1, p2, p3 ).inscribedCircle(); }
QList<QgsTriangle> QgsRegularPolygon::triangulate() const { QList<QgsTriangle> l_tri; if ( isEmpty() ) { return l_tri; } QgsPointSequence pts; pts = points(); unsigned int n = 0; while ( n < mNumberSides - 1 ) { l_tri.append( QgsTriangle( pts.at( n ), pts.at( n + 1 ), mCenter ) ); n++; } l_tri.append( QgsTriangle( pts.at( n ), pts.at( 0 ), mCenter ) ); return l_tri; }