QgsGeometry QgsTransectAlgorithm::calcTransect( const QgsPoint &point, const double angleAtVertex, const double length, const QgsTransectAlgorithm::Side orientation, const double angle ) { QgsPoint pLeft; // left point of the line QgsPoint pRight; // right point of the line QgsPolyline line; if ( ( orientation == QgsTransectAlgorithm::Right ) || ( orientation == QgsTransectAlgorithm::Both ) ) { pLeft = point.project( length, angle + 180.0 / M_PI * angleAtVertex ); if ( orientation != QgsTransectAlgorithm::Both ) pRight = point; } if ( ( orientation == QgsTransectAlgorithm::Left ) || ( orientation == QgsTransectAlgorithm::Both ) ) { pRight = point.project( -length, angle + 180.0 / M_PI * angleAtVertex ); if ( orientation != QgsTransectAlgorithm::Both ) pLeft = point; } line.append( pLeft ); line.append( pRight ); return QgsGeometry::fromPolyline( line ); }
void QgsRegularPolygon::setCenter( const QgsPoint ¢er ) { double azimuth = mCenter.azimuth( mFirstVertex ); // TODO: double inclination = mCenter.inclination(mFirstVertex); mCenter = center; mFirstVertex = center.project( mRadius, azimuth ); }
QgsRegularPolygon::QgsRegularPolygon( const QgsPoint &pt1, const QgsPoint &pt2, const int numSides ) : mCenter( QgsPoint() ) , mFirstVertex( QgsPoint() ) , mNumberSides( 0 ) , mRadius( 0.0 ) { if ( numSides >= 3 ) { mNumberSides = numSides; double azimuth = pt1.azimuth( pt2 ); QgsPoint pm = QgsGeometryUtils::midpoint( pt1, pt2 ); double length = pt1.distance( pm ); double angle = ( 180 - ( 360 / numSides ) ) / 2.0; double hypothenuse = length / cos( angle * M_PI / 180 ); // TODO: inclination mCenter = pt1.project( hypothenuse, azimuth + angle ); mFirstVertex = pt1; mRadius = qAbs( hypothenuse ); } }