依据平面圆形,在平面圆形面画12个有等间距的相同的等腰小梯形,
时间: 2024-04-05 11:32:17 浏览: 21
好的,您可以使用以下代码在平面圆形中画12个等间距的相同的等腰小梯形:
void QCircleWidget::draw_circle_scale(QPainter &p) {
p.save();
QPen pen(QColor(255, 255, 255));
pen.setWidth(5);
p.setPen(pen);
float angle = 30;
float radius = circle_R - 20;
float edgeLen = 20;
float halfWidth = 5;
for (int i = 0; i < 12; ++i) {
QPolygonF polygon;
polygon << QPointF(radius - halfWidth - edgeLen, 0)
<< QPointF(radius - halfWidth, 0)
<< QPointF(radius - halfWidth, -edgeLen)
<< QPointF(radius - halfWidth - edgeLen * qSin(qDegreesToRadians(angle / 2)), -edgeLen);
p.drawPolygon(polygon);
p.rotate(30);
}
p.restore();
}
这段代码会在平面圆形中等间距地绘制12个等腰小梯形,每个小梯形之间相隔30度,梯形的顶点分别为(radius - halfWidth - edgeLen, 0),(radius - halfWidth, 0),(radius - halfWidth, -edgeLen),(radius - halfWidth - edgeLen * qSin(qDegreesToRadians(angle / 2)), -edgeLen)。其中,angle为小梯形两边夹角的度数,edgeLen为小梯形两边的长度,halfWidth为小梯形上底边的一半长度,radius为平面圆形的半径。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)