geometry > 中心からの線とstar shape(星形)のedgeの交点を見つけて、線分を引く (平面角すべての範囲で行う) > find_rayCrossing_starShapedEged_180417 v0.5
動作環境
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
処理概要
- 星形の中心からrayを飛ばす
- rayとの交点を見つける
- 中心から交点までの線分を引く
- 中心からのrayの方向を平面角すべての範囲で処理する
code v0.5
find_rayCrossing_starShapedEged_180417.ipynb
%matplotlib inline
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt
from pylab import rcParams
from itertools import combinations
import geometry_starShaped_180428 as GSS
#import geometry_lineintersect_180415 as GLI
'''
v0.5 Apr. 29, 2018
- loop through [theta_deg]
- add get_linesegment()
- add calc_raylinegeometry()
v0.4 Apr. 29, 2018
- find crossing point instead of crossing edge
+ remove: import [geometry_lineintersect_180415]
+ import sympy
v0.3 Apr. 28, 2018
- import geometry_starShaped_180428 (v0.3)
v0.2 Apr. 28, 2018
- exclude vertices pairs not included in the output from [geometry_starShaped_180428]
- import geometry_starShaped_180428 (v0.2)
- remove: import geometry_starShaped_180415
v0.1 Apr. 17, 2018
- check the crossing
+ import [geometry_lineintersect_180415]
- define the ray from the center
+ draw the ray
+ add [xs_ray], [ys_ray]
+ add [theta_deg]
- add idxs_seq[], combs[]
- import [combinations]
- branched from [geometry_starShaped_180414.ipynb]
'''
rcParams['figure.figsize'] = 14, 7
rcParams['figure.dpi'] = 110
def calc_raylinegeometry(theta_deg):
# define the ray from the center
radius = RAD_OUTER * 1.1 # 1.1 to cross the outmost edge
xs_ray, ys_ray = [0.0], [0.0] # center
xs_ray += [radius * np.cos(np.deg2rad(theta_deg))] # outmost
ys_ray += [radius * np.sin(np.deg2rad(theta_deg))] # outmost
return xs_ray, ys_ray
def get_linesegment(xs, ys, idx0, idx1):
pa1 = sp.Point(xs[idx0], ys[idx0])
pa2 = sp.Point(xs[idx1], ys[idx1])
return sp.Segment(pa1, pa2)
# 1. obtain star shaped points
RAD_INNER = 5
RAD_OUTER = 10
xs_str, ys_str, edgeidx = GSS.get_starShaped(RAD_INNER, RAD_OUTER)
# 2. obtain combinations of points
idxs_seq = range(len(xs_str)) # sequential indices to obtain combinations
combs = [] # combinations to obtain all the edges
for acomb in combinations(idxs_seq, 2):
combs += [acomb]
print(combs)
fig = plt.figure()
ax1 = fig.add_subplot(1, 2, 1)
ax1.scatter(xs_str, ys_str)
ax1.set_xlabel('x')
ax1.set_ylabel('y')
ax1.grid(True)
# 3. fill inside star shape
RESOLUTION = 72
for theta_deg in np.linspace(0, 360, RESOLUTION):
print(theta_deg, end=':')
xs_ray, ys_ray = calc_raylinegeometry(theta_deg)
# find crossing edges
sga = get_linesegment(xs_ray, ys_ray, idx0=0, idx1=1)
for aidx in combs:
if list(aidx) not in edgeidx:
continue
b1 = np.array([xs_str[aidx[0]], ys_str[aidx[0]]])
b2 = np.array([xs_str[aidx[1]], ys_str[aidx[1]]])
sgb = get_linesegment(xs_str, ys_str, aidx[0], aidx[1])
its = sp.intersection(sga, sgb)
if its:
xs_draw = [xs_ray[0], its[0][0]]
ys_draw = [ys_ray[0], its[0][1]]
ax1.plot(xs_draw, ys_draw)
fig.tight_layout()
Author And Source
この問題について(geometry > 中心からの線とstar shape(星形)のedgeの交点を見つけて、線分を引く (平面角すべての範囲で行う) > find_rayCrossing_starShapedEged_180417 v0.5), 我々は、より多くの情報をここで見つけました https://qiita.com/7of9/items/3b2405641e71d7f4aa76著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .