在多边形内绘制线

发布于 2025-01-23 12:49:30 字数 1101 浏览 2 评论 0原文

我正在研究一个大学项目,必须阅读很多要点,将它们放入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 : image

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文