在多边形内绘制线
我正在研究一个大学项目,必须阅读很多要点,将它们放入SVG文件中,并使它们形成多边形。之后,目标E用线填充多边形。该线在它们之间具有距离(d),并且必须全部包含多边形。 我们被要求将点存储在圆形队列中,到目前为止,我所能做的就是制作多边形,并且对如何制作填充线不知道。 所有这些代码所做的就是获取要点并绘制一条线以关闭多边形(这看起来很奇怪,因为教授下令使用void Pointer,圆形队列和结构)
这就是我们给出的示例:
while (aux2 != size) {
p1 = getElement(q, aux); // 0 1 2
p2 = getElement(q, aux2); // 1 2 3
aux = aux2;
aux2++;
x1 = getpX(p1);
x2 = getpX(p2);
y1 = getpY(p1);
y2 = getpY(p2);
fprintf(txt, "Criada linha de borda: x1 = %lf, y1 = %lf, x2 = %lf, y2 = %lf, stroke = %s\n", x1, y1, x2, y2, corb);
fprintf(svg, "\t<line id=\"%d\" x1=\"%lf\" y1=\"%lf\" x2=\"%lf\" y2=\"%lf\" stroke=\"%s\" />\n", i, x1, y1, x2, y2, corb);
i++;
if (y1 < menorY) {
menorY = y1;
}
if (y2 < menorY) {
menorY = y2;
}
if (y1 > maiorY) {
maiorY = y2;
}
if (y2 > maiorY) {
maiorY = y2;
}
}
p1 = getElement(q, 0);
x1 = getpX(p1);
y1 = getpY(p1);
谢谢
I'm working on a college project and a have to read lot of points, put them in a SVG file and make them form a polygon. After that the goal e to fill the polygon with lines. This lines have a distance (d) between them and must be all contained within the polygon.
We were asked to store the points in a circular queue and so far all I could do was to make the polygon, and have no clue on how to make the filling lines.
All this code does is get the points and draw a line to close the polygon (it may look weird because the professor ordered to use void pointers, circular queues and structs)
this is the example we were given :
while (aux2 != size) {
p1 = getElement(q, aux); // 0 1 2
p2 = getElement(q, aux2); // 1 2 3
aux = aux2;
aux2++;
x1 = getpX(p1);
x2 = getpX(p2);
y1 = getpY(p1);
y2 = getpY(p2);
fprintf(txt, "Criada linha de borda: x1 = %lf, y1 = %lf, x2 = %lf, y2 = %lf, stroke = %s\n", x1, y1, x2, y2, corb);
fprintf(svg, "\t<line id=\"%d\" x1=\"%lf\" y1=\"%lf\" x2=\"%lf\" y2=\"%lf\" stroke=\"%s\" />\n", i, x1, y1, x2, y2, corb);
i++;
if (y1 < menorY) {
menorY = y1;
}
if (y2 < menorY) {
menorY = y2;
}
if (y1 > maiorY) {
maiorY = y2;
}
if (y2 > maiorY) {
maiorY = y2;
}
}
p1 = getElement(q, 0);
x1 = getpX(p1);
y1 = getpY(p1);
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论