LoginSignup
0
0

More than 5 years have passed since last update.

Sympy > Polygon() > ValueError: Nonzero coordinates cannot be removed. > X-Y平面上にない時にエラー?

Last updated at Posted at 2018-04-30
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04.4 LTS desktop amd64
TensorFlow v1.7.0
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0
MATLAB R2017b (Home Edition)
ADDA v.1.3b6
gnustep-gui-runtime v0.24.0-3.1
PyMieScatt v1.7.0
Sympy v1.1.1
test_sympy_3D_180430.ipynb
import sympy as sp

ERROR_COND = True

# Triangles to define the shape of the particle
DIST_POLY = 7
points = []
points += [sp.Point3D(0, DIST_POLY, 0)]
points += [sp.Point3D(DIST_POLY, DIST_POLY, 0)]
if ERROR_COND:
    points += [sp.Point3D(DIST_POLY, 0, DIST_POLY)]
else:
    points += [sp.Point3D(DIST_POLY, 0, 0)]

atpl = tuple(points)
symplys = sp.Polygon(*atpl)
print(symplys)

run
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-44-5b3dabb8b0c5> in <module>()
     14 
     15 atpl = tuple(points)
---> 16 symplys = sp.Polygon(*atpl)
     17 print(symplys)

/usr/local/lib/python3.5/dist-packages/sympy/geometry/polygon.py in __new__(cls, *args, **kwargs)
    124             return RegularPolygon(*args, **kwargs)
    125 
--> 126         vertices = [Point(a, dim=2, **kwargs) for a in args]
    127 
    128         # remove consecutive duplicates

/usr/local/lib/python3.5/dist-packages/sympy/geometry/polygon.py in <listcomp>(.0)
    124             return RegularPolygon(*args, **kwargs)
    125 
--> 126         vertices = [Point(a, dim=2, **kwargs) for a in args]
    127 
    128         # remove consecutive duplicates

/usr/local/lib/python3.5/dist-packages/sympy/geometry/point.py in __new__(cls, *args, **kwargs)
    155                         'warn' or 'ignore'.'''))
    156         if any(i for i in coords[dim:]):
--> 157             raise ValueError('Nonzero coordinates cannot be removed.')
    158         if any(a.is_number and im(a) for a in coords):
    159             raise ValueError('Imaginary coordinates are not permitted.')

ValueError: Nonzero coordinates cannot be removed.

上記のエラーが出る。

エラーが出ない条件としては、Z軸の値を0で合わせること。

傾いた平面ではエラーになるのだろうか。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0