geometry > numpy > star shaped (星形) の頂点座標と辺の情報(頂点インデックスのペア)を得る > v0.5 取得コードと確認用描画コード

```txt:動作環境
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
```


- v0.1: [geometry > numpy > pentagon (五角形）の座標を得る | Matplotlibでの描画 > v0.1, v0.2](https://qiita.com/7of9/items/fa0e7fb3f6b0c87f70cf)
- [geometry > numpy > star shaped (星形) の座標を得る | Matplotlibでの描画 > v0.3:座標は得られた | v0.4: モジュール化](https://qiita.com/7of9/items/e23c81db584ffae7edd3)


星形の形状内部をfillする方法を検討することで、Gaussian random sphereの内部fill方法を探している。

頂点座標だけで星形をfillしようとしていたが、その場合、五角形と星形の区別ができない。
辺の情報が別途必要になる。

### 頂点と辺の情報を返す

```geometry_starShaped_180428.py
import numpy as np

'''
v0.1 Apr. 28, 2018
  - get_starShaped() returns EDGE_IDXS[]
  - remove: import [matplotlib.pyplot]
    + not needed
=== branched from [geometry_starShaped_180415.py] ===
v0.1 Apr. 15, 2018
  - add Test_get_starShaped()
  - separated from [geometry_starShaped_180414.ipynb]
'''

NUM_VERT = 5  # number of vertices (5: for pentagon)


def get_pentagon(radius, upward):
    xs, ys = [], []
    for idx in range(NUM_VERT):
        theta = 2.0 * np.pi * idx / NUM_VERT
        if upward:
            theta += np.pi / 2.0  # to put the one vertex upward
        else:
            theta -= np.pi / 2.0  # to put the one vertex downward
        xs += [radius * np.cos(theta)]
        ys += [radius * np.sin(theta)]
    return xs, ys

# vertex indices pair to form edges
#     only outermost edges are taken in to account
EDGE_IDXS = [
    [2, 5], [3, 5], [3, 6], [4, 6], [4, 7],
    [0, 7], [0, 8], [1, 8], [1, 9], [2, 9]
    ]


def get_starShaped(rad_inner, rad_outer):
    xis, yis = get_pentagon(rad_inner, upward=False)
    xos, yos = get_pentagon(rad_outer, upward=True)
    vtx_xs = [*xis, *xos]
    vtx_ys = [*yis, *yos]
    return vtx_xs, vtx_ys, EDGE_IDXS


def Test_get_starShaped():
    vtxs, vtys, edgidx = get_starShaped(rad_inner=5, rad_outer=10)
    return vtxs, vtys, edgidx


if __name__ == '__main__':
    res = Test_get_starShaped()
    print(res)

```

### 描画

上記のコードを元にMatplotlibで描画してみる。

```py:draw_starShaped_180428.ipynb
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
from pylab import rcParams
import geometry_starShaped_180428 as GSS

'''
v0.1 Apr. 28, 2018
  - draw edges
  - import geometry_starShaped_180428
  - remove: import geometry_starShaped_180415
=== branched from [geometry_starShaped_180414.ipynb] ===
v0.4 Apr. 15, 2018
  - tweak figure size
  - show 2 results
  - separate get_pentagon() and get_starShaped() to [geometry_starShaped_180415]
v0.3 Apr. 14, 2018
  - add get_starShaped()
v0.2 Apr. 14, 2018
  - fix bug: get_pentagon() did not use [radius] arg
  - get_pentagon() takes [upward] arg
v0.1 Apr. 14, 2018
  - add get_pentagon()
      + to obtain pentagon geometry
'''

rcParams['figure.figsize'] = 14, 7
rcParams['figure.dpi'] = 110

RAD_INNER = 5
RAD_OUTER = 10
vtx_xs, vtx_ys, edge_idxs = GSS.get_starShaped(RAD_INNER, RAD_OUTER)

fig = plt.figure()

ax1 = fig.add_subplot(1, 2, 1)
ax1.scatter(xs1, ys1)
ax1.set_xlabel('x')
ax1.set_ylabel('y')
ax1.grid(True)

for apair in edge_idxs:
    idx0, idx1 = apair[0], apair[1]
    xs = [vtx_xs[idx0], vtx_xs[idx1]]
    ys = [vtx_ys[idx0], vtx_ys[idx1]]
    ax1.plot(xs, ys)

fig.tight_layout()

```

![qiita.png](https://qiita-image-store.s3.amazonaws.com/0/32870/f9121bc9-883f-c9e5-b376-84858abaa05e.png)