List to Polygon

174 views
Skip to first unread message

Jakob Hammersen

unread,
Dec 31, 2023, 2:02:20 PM12/31/23
to sympy
Hello everyone,
i have a question to the sympy geometry module.
I have a list of tuple where each tuple is representing a vertex of the polygon. I tried to submit the list to the Polygon-function, but i get the error "ValueError: Nonzero coordinates cannot be removed". Does anyone have an idea on how to fix this?
Thanks in advance
Jakob

phi ARCHITECT

unread,
Dec 31, 2023, 2:16:54 PM12/31/23
to sy...@googlegroups.com
Can you show the section of code?

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/cd496711-4c6d-4696-a058-ccc94ebdeddcn%40googlegroups.com.

Jakob Hammersen

unread,
Jan 1, 2024, 12:31:50 PM1/1/24
to sympy
polygon = [(0,0),(200,0),(200,250),(150,100)]

poly = Polygon(polygon)

this is what im trying to do but as I said, I get a " ValueError: Nonzero coordinates cannot be removed" when i run the code.

phi ARCHITECT

unread,
Jan 1, 2024, 1:56:30 PM1/1/24
to sy...@googlegroups.com
This stumped me for a moment, too,

You need to expand the list of tuples:

poly = Polygon(*polygon)                                                                                                                                                                    
  

Jakob Hammersen

unread,
Jan 1, 2024, 2:24:24 PM1/1/24
to sympy
Thanks alot, now it works

phi ARCHITECT

unread,
Jan 1, 2024, 2:26:46 PM1/1/24
to sy...@googlegroups.com
Yeah - the error doesn't make sense for the context

Sangyub Lee

unread,
Jan 4, 2024, 9:36:49 AM1/4/24
to sympy
I indeed think that it is confusing error,
However, it may be a bit difficult to correct the error to raise the error more contextually in this case though.
Because there are many variations of input, from ‚Polygon’.

It is recommended to always consult the documentation before using functions, and don’t use functions plausibly.
I think that not that urgent to fix, because it comes from mistake at the first place.
Reply all
Reply to author
Forward
0 new messages