Skip to content

Visualizing non-convex polygons #806

Answered by marcomusy
ZiguoAtGitHub asked this question in Q&A
Discussion options

You must be logged in to vote

I would write it as:

from vedo import *
B, D, TF, TW, BB, TFB = 500, 800, 50, 35, 650, 20
plist = [
    (-B / 2, D / 2),
    (B / 2, D / 2),
    (B / 2, D / 2 - TF),
    (TW / 2, D / 2 - TF),
    (TW / 2, -D / 2 + TFB),
    (BB / 2, -D / 2 + TFB),
    (BB / 2, -D / 2),
    (-BB / 2, -D / 2),
    (-BB / 2, -D / 2 + TFB),
    (-TW / 2, -D / 2 + TFB),
    (-TW / 2, D / 2 - TF),
    (-B / 2, D / 2 - TF),
]
faces = [(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)]
msh = Mesh([plist, faces]).triangulate().c("blue4").lw(1)
show(msh, axes=1).close()

do not repeat 0 to define the single face. Note that a single face which is not convex cannot be rendered, so you need .triangulate().

Hope this helps.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ZiguoAtGitHub
Comment options

@ZiguoAtGitHub
Comment options

@marcomusy
Comment options

@PinkMushroom
Comment options

Answer selected by marcomusy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants