2022-02-04 20:24:40 +09:00
|
|
|
|
{
|
|
|
|
|
"cells": [
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "62555b4e-5276-4457-a870-dc3d6edb65f9",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"# SMS Shape Notebook"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "7f65558a-315c-44cf-a3dc-17a92eefe171",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## 準備 Preparation"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "1bba5694-e605-4c44-b263-aa9beb3ac116",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# 必要なパッケージをインストール\n",
|
|
|
|
|
"# Install the required packages\n",
|
|
|
|
|
"!pip install numpy matplotlib"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"execution_count": 2,
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"id": "bb2b194e-b451-4a35-ba17-f74619d658c5",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"import numpy as np\n",
|
|
|
|
|
"from numpy import array\n",
|
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
|
"from matplotlib.path import Path\n",
|
|
|
|
|
"from matplotlib import patches\n",
|
|
|
|
|
"import matplotlib.ticker as plticker\n",
|
|
|
|
|
"normalize = lambda x: x/np.linalg.norm(x)\n",
|
|
|
|
|
"tau = 2*np.pi"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "00ec378c-11c0-48fa-b863-430c82d5b015",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"### 日本語を含む図の作成 <br> Making plot containing Japanese\n",
|
|
|
|
|
"日本語を含む図を作成する際に、次のパッケージをインストールしてimportする必要があります。 \n",
|
|
|
|
|
"If you are making plots containing Japanese, you have to install\n",
|
|
|
|
|
"and import the following package."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "cd3ea05f-666b-420c-a020-e53b01ade1ae",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"!pip install japanize_matplotlib"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "b4fa0f55-3570-47f6-9f5f-0da6bb6e9f7f",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"import japanize_matplotlib"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "528ea79d-13f4-4c98-a306-1fa55071f05c",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"### class of shapes\n",
|
|
|
|
|
"多角形と凸多面体を実装したクラス \n",
|
|
|
|
|
"Classes that implement polygon and convex polyhedron"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"execution_count": 3,
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"id": "21603f5b-59ad-45d3-945e-58978b8b3099",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# 多角形\n",
|
|
|
|
|
"class Polygon():\n",
|
|
|
|
|
" def __init__(self, verts):\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" * self.verts:\n",
|
|
|
|
|
" 頂点の配列\n",
|
|
|
|
|
" Array of vertices\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" self.verts = np.array(verts)\n",
|
|
|
|
|
" def clipLine(self, p, n, c=0):\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" 半平面 (x-p)・n >= c との共通部分の多角形を返す\n",
|
|
|
|
|
" Return the intersection polygon with half plane (x-p)・n >= c\n",
|
|
|
|
|
" * p:\n",
|
|
|
|
|
" 直線上の一点\n",
|
|
|
|
|
" Any point on the line\n",
|
|
|
|
|
" * n:\n",
|
|
|
|
|
" 直線の法線ベクトル\n",
|
|
|
|
|
" Normal vector of the line\n",
|
|
|
|
|
" * c:\n",
|
|
|
|
|
" 定数\n",
|
|
|
|
|
" Constant\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" p, n, c = map(array, (p, n, c))\n",
|
|
|
|
|
" r = np.dot(self.verts-p, n)-c\n",
|
|
|
|
|
" verts = []\n",
|
|
|
|
|
" for i in range(len(r)):\n",
|
|
|
|
|
" v0, r0 = self.verts[i-1], r[i-1]\n",
|
|
|
|
|
" v1, r1 = self.verts[i], r[i]\n",
|
|
|
|
|
" if r1 >= 0:\n",
|
|
|
|
|
" if r0 < 0: # (- +)\n",
|
|
|
|
|
" verts.append((r1*v0-r0*v1)/(-r0+r1))\n",
|
|
|
|
|
" verts.append(v1)\n",
|
|
|
|
|
" elif r0 >= 0: # (+ -)\n",
|
|
|
|
|
" verts.append((-r1*v0+r0*v1)/(r0-r1))\n",
|
|
|
|
|
" return Polygon(array(verts).reshape(-1, self.verts.shape[1]))\n",
|
|
|
|
|
" def path(self, axis=(0, 1)):\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" Get Path instance\n",
|
|
|
|
|
" * axis:\n",
|
|
|
|
|
" 用いる軸を指定(デフォルト:xとy)\n",
|
|
|
|
|
" - ``(0, 2)'': xとz\n",
|
|
|
|
|
" - ``(2, 1)'': zとy\n",
|
|
|
|
|
" The axes to use (Defaults: x, y)\n",
|
|
|
|
|
" - ``(0, 2)'': x and z\n",
|
|
|
|
|
" - ``(2, 1)'': z and y\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" if self.verts.shape[0] == 0: return Path(np.zeros((0, 2)))\n",
|
|
|
|
|
" verts = self.verts[:, axis]\n",
|
|
|
|
|
" assert verts.shape[-1] == 2, 'verts should be 2D'\n",
|
|
|
|
|
" return Path([*verts, (0, 0)], [\n",
|
|
|
|
|
" Path.MOVETO,\n",
|
|
|
|
|
" *(Path.LINETO for _ in range(1, verts.shape[0])),\n",
|
|
|
|
|
" Path.CLOSEPOLY,\n",
|
|
|
|
|
" ])\n",
|
|
|
|
|
" def plot(self, axis=(0, 1), margin=0.05, facecolor='#2ee5b8', lw=1):\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" この多角形を描画し、figとaxを返す\n",
|
|
|
|
|
" Plot this polygon and return ``fig'' and ``ax''\n",
|
|
|
|
|
" * axis:\n",
|
|
|
|
|
" self.pathを参照\n",
|
|
|
|
|
" See self.path\n",
|
|
|
|
|
" * margin:\n",
|
|
|
|
|
" Margin of the plot\n",
|
|
|
|
|
" * facecolor:\n",
|
|
|
|
|
" 面の色\n",
|
|
|
|
|
" Face color\n",
|
|
|
|
|
" * lw:\n",
|
|
|
|
|
" 線の太さ\n",
|
|
|
|
|
" Line width\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" fig, ax = plt.subplots()\n",
|
|
|
|
|
" if self.verts.shape[0] == 0: return fig, ax\n",
|
|
|
|
|
" # path\n",
|
|
|
|
|
" path = self.path(axis)\n",
|
|
|
|
|
" patch = patches.PathPatch(path, facecolor=facecolor, lw=lw)\n",
|
|
|
|
|
" ax.add_patch(patch)\n",
|
|
|
|
|
" verts = self.verts[:, axis]\n",
|
|
|
|
|
" xMax, yMax = verts.max(axis=0)\n",
|
|
|
|
|
" xMin, yMin = verts.min(axis=0)\n",
|
|
|
|
|
" xMg, yMg = verts.ptp(axis=0)*margin\n",
|
|
|
|
|
" ax.set_xlim(xMin-xMg, xMax+xMg)\n",
|
|
|
|
|
" ax.set_ylim(yMin-yMg, yMax+yMg)\n",
|
|
|
|
|
" return fig, ax\n",
|
|
|
|
|
" def __repr__(self):\n",
|
|
|
|
|
" return f'Polygon with {len(self.verts)}vertices:\\n{self.verts}'\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# 多面体\n",
|
|
|
|
|
"class Polyhedron:\n",
|
|
|
|
|
" def __init__(self, verts, edges):\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" * self.verts:\n",
|
|
|
|
|
" 頂点の配列\n",
|
|
|
|
|
" Array of vertices\n",
|
|
|
|
|
" * self.edges:\n",
|
|
|
|
|
" 辺(2頂点の番号)の配列\n",
|
|
|
|
|
" Array of edges (indices of 2 vertices)\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" self.verts = np.array(verts)\n",
|
|
|
|
|
" self.edges = edges\n",
|
|
|
|
|
" def clipPlane(self, p, n, c=0):\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" 半空間 (x-p)・n >= c との共通部分の多面体を返す\n",
|
|
|
|
|
" Return the intersection polyhedron with half space (x-p)・n >= c\n",
|
|
|
|
|
" * p:\n",
|
|
|
|
|
" 平面上の一点\n",
|
|
|
|
|
" Any point on the plane\n",
|
|
|
|
|
" * n:\n",
|
|
|
|
|
" 直線の法線ベクトル\n",
|
|
|
|
|
" Normal vector of the plane\n",
|
|
|
|
|
" * c:\n",
|
|
|
|
|
" 定数\n",
|
|
|
|
|
" Constant\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" p, n, c = map(array, (p, n, c))\n",
|
|
|
|
|
" r = np.dot(self.verts-p, n)-c\n",
|
|
|
|
|
" rb = [s>=0 for s in r]\n",
|
|
|
|
|
" # map vertex indices old to new\n",
|
|
|
|
|
" io2n = {\n",
|
|
|
|
|
" iO: iN\n",
|
|
|
|
|
" for iN, iO in enumerate(iO for iO, sb in enumerate(rb) if sb)\n",
|
|
|
|
|
" }\n",
|
|
|
|
|
" # handle old vert\n",
|
|
|
|
|
" verts = [v for v, sb in zip(self.verts, rb) if sb]\n",
|
|
|
|
|
" edges = []\n",
|
|
|
|
|
" for i0, i1 in self.edges:\n",
|
|
|
|
|
" if rb[i0] and rb[i1]:\n",
|
|
|
|
|
" # remain\n",
|
|
|
|
|
" edges.append((io2n[i0], io2n[i1]))\n",
|
|
|
|
|
" elif rb[i0] or rb[i1]:\n",
|
|
|
|
|
" # new vert\n",
|
|
|
|
|
" v0, r0 = self.verts[i0], abs(r[i0])\n",
|
|
|
|
|
" v1, r1 = self.verts[i1], abs(r[i1])\n",
|
|
|
|
|
" vN = (r1*v0+r0*v1)/(r0+r1)\n",
|
|
|
|
|
" edges.append((io2n[i0 if rb[i0] else i1], len(verts)))\n",
|
|
|
|
|
" verts.append(vN)\n",
|
|
|
|
|
" # else drop edge\n",
|
|
|
|
|
" # add new face\n",
|
|
|
|
|
" nOld = len(io2n)\n",
|
|
|
|
|
" vNews = verts[nOld:]\n",
|
|
|
|
|
" if len(vNews):\n",
|
|
|
|
|
" assert len(vNews) >= 3\n",
|
|
|
|
|
" p0, p1 = vNews[:2]\n",
|
|
|
|
|
" # choose p1-p0 as e1\n",
|
|
|
|
|
" e1 = normalize(p1-p0)\n",
|
|
|
|
|
" # choose e2 that ⊥ n, e1\n",
|
|
|
|
|
" e2 = normalize(np.cross(n, e1))\n",
|
|
|
|
|
" # set (p0+p1)/2 as new origin, and use {e1, e2} as new basis\n",
|
|
|
|
|
" cNews = np.dot(vNews-(p0+p1)/2, array([e1, e2]).transpose())\n",
|
|
|
|
|
" # indices of new verts CCW\n",
|
|
|
|
|
" jNews = nOld+np.arctan2(cNews[:,0], cNews[:,1]).argsort()\n",
|
|
|
|
|
" # add to edge\n",
|
|
|
|
|
" for i in range(len(vNews)):\n",
|
|
|
|
|
" edges.append((jNews[i-1], jNews[i]))\n",
|
|
|
|
|
" # final\n",
|
|
|
|
|
" return Polyhedron(array(verts).reshape(-1, self.verts.shape[1]), edges)\n",
|
|
|
|
|
" def slicePlane(self, p, n):\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" 平面 (x-p)・n=0 との共通部分(多角形)の頂点を返す\n",
|
|
|
|
|
" Return vertices of intersection(polygon) with plane (x-p)・n=0\n",
|
|
|
|
|
" * p:\n",
|
|
|
|
|
" 平面上の一点\n",
|
|
|
|
|
" Any point on the plane\n",
|
|
|
|
|
" * n:\n",
|
|
|
|
|
" 平面の法線ベクトル\n",
|
|
|
|
|
" Normal vector of the plane\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" p, n = map(array, (p, n))\n",
|
|
|
|
|
" r = np.dot(self.verts-p, n)\n",
|
|
|
|
|
" vNews = []\n",
|
|
|
|
|
" # handle old verts\n",
|
|
|
|
|
" for i0, i1 in self.edges:\n",
|
|
|
|
|
" # two vertices on other side of the plane\n",
|
|
|
|
|
" if np.sign(r[i0]) != np.sign(r[i1]):\n",
|
|
|
|
|
" v0, r0 = self.verts[i0], abs(r[i0])\n",
|
|
|
|
|
" v1, r1 = self.verts[i1], abs(r[i1])\n",
|
|
|
|
|
" vN = (r1*v0+r0*v1)/(r0+r1)\n",
|
|
|
|
|
" vNews.append(vN)\n",
|
|
|
|
|
" # new verts\n",
|
|
|
|
|
" if len(vNews):\n",
|
|
|
|
|
" assert len(vNews) >= 2\n",
|
|
|
|
|
" p0, p1 = vNews[:2]\n",
|
|
|
|
|
" e1 = normalize(p1-p0)\n",
|
|
|
|
|
" e2 = normalize(np.cross(n, e1))\n",
|
|
|
|
|
" cNews = np.dot(vNews-(p0+p1)/2, array([e1, e2]).transpose())\n",
|
|
|
|
|
" jNews = np.arctan2(cNews[:,0], cNews[:,1]).argsort()\n",
|
|
|
|
|
" return array([vNews[j] for j in jNews])\n",
|
|
|
|
|
" else:\n",
|
|
|
|
|
" return array(np.zeros((0, self.verts.shape[-1])))\n",
|
|
|
|
|
" def __repr__(self):\n",
|
|
|
|
|
" return 'Polyhedron with %d vertices and %d edges:\\n%s'%(\n",
|
|
|
|
|
" len(self.verts), len(self.edges),\n",
|
|
|
|
|
" #'\\n'.join(line for line in str(\n",
|
|
|
|
|
" array([self.verts[[i0, i1]] for i0, i1 in self.edges])\n",
|
|
|
|
|
" #).split('\\n') if line)\n",
|
|
|
|
|
" )"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"execution_count": 4,
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"id": "a2316c48-2614-4f93-b152-f0d8ab379c9b",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# 等高線図\n",
|
|
|
|
|
"def contourMap(poly, ys, colors, margin=0.05, lw=1):\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" 与えたy座標に対して多面体の等高線図を描画\n",
|
|
|
|
|
" Plot a contour map of polyhedron with given y\n",
|
|
|
|
|
" * poly:\n",
|
|
|
|
|
" 多面体\n",
|
|
|
|
|
" Polyhedron\n",
|
|
|
|
|
" * ys:\n",
|
|
|
|
|
" 等高線のy座標配列\n",
|
|
|
|
|
" Array of y coordinate of the contour map\n",
|
|
|
|
|
" * colors:\n",
|
|
|
|
|
" 各層の色の配列\n",
|
|
|
|
|
" Array of colors of each layer\n",
|
|
|
|
|
" * margin:\n",
|
|
|
|
|
" Margin of the plot\n",
|
|
|
|
|
" * lw:\n",
|
|
|
|
|
" 線の太さ\n",
|
|
|
|
|
" Line width\n",
|
|
|
|
|
" '''\n",
|
|
|
|
|
" fig, ax = plt.subplots()\n",
|
|
|
|
|
" xyMin = array([np.inf]*2)\n",
|
|
|
|
|
" xyMax = -xyMin\n",
|
|
|
|
|
" for y, color in zip(ys, colors):\n",
|
|
|
|
|
" verts = poly.slicePlane((0, y, 0), (0, 1, 0))\n",
|
|
|
|
|
" verts = verts[:, (0, 2)] # (x, z)\n",
|
|
|
|
|
" path = Polygon(verts).path()\n",
|
|
|
|
|
" ax.add_patch(patches.PathPatch(path, facecolor=color, lw=lw))\n",
|
|
|
|
|
" # update xyMin, xyMax\n",
|
|
|
|
|
" xyMin = np.min([xyMin, *verts], axis=0)\n",
|
|
|
|
|
" xyMax = np.max([xyMax, *verts], axis=0)\n",
|
|
|
|
|
" # 座標の範囲を設定\n",
|
|
|
|
|
" # set range of coordinate\n",
|
|
|
|
|
" xyRg = (xyMax-xyMin)*margin\n",
|
|
|
|
|
" xyMax += xyRg\n",
|
|
|
|
|
" xyMin -= xyRg\n",
|
|
|
|
|
" ax.set_xlim(xyMin[0], xyMax[0])\n",
|
|
|
|
|
" ax.set_ylim(xyMin[1], xyMax[1])\n",
|
|
|
|
|
" return fig, ax"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "83b62be5-adad-43f4-af69-6a0895c4c6da",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## すり抜け可能領域の可視化 <br> Visualization of the area that you can clip through"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "05bb2811-1590-4315-8c74-1cf3643683c0",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"### 三角形の座標\n",
|
|
|
|
|
"調べたい三角形の座標を入力しましょう。例としてシレナINの地面三角形を使います。 \n",
|
|
|
|
|
"Fill in the coordinates of the triangle that you want to research on.\n",
|
|
|
|
|
"I will use the floor triangle of Sirena IN as an example."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "b6d717b7-2cb5-4843-850c-deefd755cac4",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"tri = array([\n",
|
|
|
|
|
" (-331.148, 2064.531, 1757.190),\n",
|
|
|
|
|
" (174.367, 2357.666, 1443.628),\n",
|
|
|
|
|
" (-174.367, 2357.666, 1443.628),\n",
|
|
|
|
|
"])"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "958256e5-ba48-4d89-a5d9-cfffedd2095c",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"hex形式の座標データを使う場合、次のように配列に変換することができます。 \n",
|
|
|
|
|
"If you use the hex form of the coordinate data,\n",
|
|
|
|
|
"you can convert it to array as shown below."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"execution_count": 23,
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"id": "f0c3daf3-4b26-4a4e-a7bf-ad6a7e7e89a0",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"array([[-331.14801025, 2064.53100586, 1757.18994141],\n",
|
|
|
|
|
" [ 174.36700439, 2357.66601562, 1443.62805176],\n",
|
|
|
|
|
" [-174.36700439, 2357.66601562, 1443.62805176]])"
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"execution_count": 23,
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"raw = 'C3 A5 92 F2 45 01 08 7F 44 DB A6 14 43 2E 5D F4 45 13 5A A8 44 B4 74 19 C3 2E 5D F4 45 13 5A A8 44 B4 74 19'\n",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"tri = np.frombuffer(bytes.fromhex(raw), '>f').astype('d').reshape(-1, 3)[:3, :]\n",
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"tri"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "a59964d7-767e-49ee-b510-c9f9fafb62ce",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"### すり抜け可能領域 <br> The area that you can clip through\n",
|
|
|
|
|
"マリオの位置を`M`、水平速度を`vh`、鉛直速度を`vy`とし、三角形の境界は水平方向で`B`を通って`nB`を単位法線ベクトル(三角形外向き)とした直線とし、すり抜ける地面の高さを`yB`とすると、すり抜ける条件は次の通りです。 \n",
|
|
|
|
|
"1. `M`が三角形の上方にある\n",
|
|
|
|
|
"2. 1QF後マリオが地面の判定の下にいる:`M.y + vy/4 < yB-30`\n",
|
|
|
|
|
"3. 1QF後マリオが水平方向で境界を超える:`(M+vh/4-B)・nB > 0`\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Let `M` be Mario's position,\n",
|
|
|
|
|
"`vh` be his horizontal speed, and `vy` be his vertical speed,\n",
|
|
|
|
|
"the border of the triangle be a line passes `B`\n",
|
|
|
|
|
"with normalized normal vector `nB` (point outward from the triangle)\n",
|
|
|
|
|
"horizontally, and the height of the triangle Mario that clips though be `yB`,\n",
|
|
|
|
|
"he can clip through the floor if the following conditions are met.\n",
|
|
|
|
|
"1. `M` is above the triangle\n",
|
|
|
|
|
"2. Mario is below the hitbox of the floor triangle after 1 QF: `M.y + vy/4 < yB-30`\n",
|
|
|
|
|
"3. Mario cross the border horizontally after 1 QF: `(M+vh/4-B)・nB > 0`"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"execution_count": 6,
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"id": "4a7cc39b-1506-46ba-a6d9-2f9714d6b747",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"def getClipThroughArea(vh, vy, B, nB, yB):\n",
|
|
|
|
|
" # 法線ベクトルを正規化\n",
|
|
|
|
|
" # normalize normal vector\n",
|
|
|
|
|
" nB = normalize(nB) \n",
|
|
|
|
|
" \n",
|
|
|
|
|
" # 条件1において、三角形以上の領域は無限に続く三角柱であるが、\n",
|
|
|
|
|
" # 無限の処理はややこしいため、ここでは適当な上限(yMax+75)を設けて\n",
|
|
|
|
|
" # 多面体である三角柱にする。\n",
|
|
|
|
|
" # For condition 1, the area above the triangle is a\n",
|
|
|
|
|
" # triangular prism that extends infinitely.\n",
|
|
|
|
|
" # However, it is difficult to deal with infinity,\n",
|
|
|
|
|
" # and therefore we choose an appropriate upper bound (yMax+75)\n",
|
|
|
|
|
" # and make the area a finite triangular prism.\n",
|
|
|
|
|
" poly = Polyhedron([\n",
|
|
|
|
|
" # 下の三角形 = 地面三角形\n",
|
|
|
|
|
" # the bottom triangle = the floor triangle\n",
|
|
|
|
|
" *tri,\n",
|
|
|
|
|
" # 上の三角形:xとz座標を固定してyをyMax+75とする\n",
|
|
|
|
|
" # the upper triangle: fix x and z coordinate and set y=yMax+75\n",
|
|
|
|
|
" *(\n",
|
|
|
|
|
" [v[0], tri[:,1].max()+75, v[2]]\n",
|
|
|
|
|
" for v in tri\n",
|
|
|
|
|
" )\n",
|
|
|
|
|
" ], [\n",
|
|
|
|
|
" e for i in range(3)\n",
|
|
|
|
|
" for e in [\n",
|
|
|
|
|
" # 下の三角形の辺\n",
|
|
|
|
|
" # the edge of the bottom triangle\n",
|
|
|
|
|
" (i, (i+1)%3),\n",
|
|
|
|
|
" # 上の三角形の辺\n",
|
|
|
|
|
" # the edge of the upper triangle\n",
|
|
|
|
|
" (3+i, 3+(i+1)%3),\n",
|
|
|
|
|
" # 下の三角形から上の三角形を繋ぐ辺\n",
|
|
|
|
|
" # the edge that connect the bottom triangle and the upper triangle\n",
|
|
|
|
|
" (i, 3+i),\n",
|
|
|
|
|
" ]\n",
|
|
|
|
|
" ])\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" # 条件2において、M.y + vy/4 < yB-30より、\n",
|
|
|
|
|
" # For confition 2, since M.y + vy/4 < yB-30,\n",
|
|
|
|
|
" # -M.y > vy/4+30-yB\n",
|
|
|
|
|
" # (M-0)・(0, -1, 0) > vy/4+30-yB\n",
|
|
|
|
|
" poly = poly.clipPlane((0, 0, 0), (0, -1, 0), vy/4+30-yB)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" # 条件3において、(M-(B-vh/4))・nB > 0\n",
|
|
|
|
|
" # For condition 3, (M-(B-vh/4))・nB > 0\n",
|
|
|
|
|
" poly = poly.clipPlane(B-vh/4, nB)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" # 条件1~3を満たす領域はpolyとなる\n",
|
|
|
|
|
" # Now the area satisfies condition 1.~3. is exactly poly\n",
|
|
|
|
|
" return poly"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "7f2c757f-995a-4075-9bf4-478a7377a713",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"シレナINの例で定数は次のように与えられたとすると、上記の関数を用いれば、すり抜け可能領域が求まります。 \n",
|
|
|
|
|
"In the Sirena IN example, suppose the constants are given as below.\n",
|
|
|
|
|
"You can then simply use the function above to get the area\n",
|
|
|
|
|
"that you can clip though."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"execution_count": 24,
|
2022-02-04 20:24:40 +09:00
|
|
|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3akJqXQsnwd0lp0Z/ushX6XJCKlhAI9CE488URGf/QJ3435kpwXPmVDj6Hkbtrqd1kiEuYU6EF07bXXsjIhidsaXkBaVHe2fj9H0weISNAo0IOsSpUqvPvGm8yKnkyZdyeR9cDL7Fu30e+yRCQMKdCLyWWXXUbKsjgeurwFadf1ZMuXU3W1LiIBpUAvRhUqVGDQiy8x/+f/UH38XNbfMYC9a9b6XZaIhAkFug8uuOACYhcs4omb7yTjpr5sHvGNJvsSkeOmQPdJ2bJl6ffEE8QuXES9ucvJbPcEe5av8bssESnBFOg+O+uss/jtpzkMeqQX625/ho3DvtRkXyJyTBToISAiIoKujzxCcmwc567YSEabXuxapsm+ROToKNBDSP369Zn5w2SGP/cyGx94hY0vfazJvkSkyBToIcbMuOuuu1iZmMTl28uQFtWdHfNi/S5LREoABXqIqlOnDt+MHceX745g++Nvs+HJd9i/bYffZYlICFOgh7gbb7yR1KQUWlc9lbQW3dg2Y77fJYlIiFKglwAnnHACoz78iOix48l9eTRZ3YaQu3Gr32WJSIhRoJcg11xzDSsTkrjjrIv4I6o7W7/9SdMHiMj/UaCXMJUrV+bt14fx8+SplP/wR7I6v0ROZrbfZYlICFCgl1CXXnopSUuW0fWq60hv8xhbxkzG5eX5XZaI+EiBXoKVL1+eFwc+z8L//EKNSfNZd/sz7F2d6XdZIuITBXoYOO+881j62wL6d7iXjHZPsOn9r3G5muxLpLRRoIeJMmXK0LdPH+IXx3Da/N/JbNuX3Umr/S5LRIqRAj3MnHHGGcyb9RODe/Rl/Z3PsnHo5+TtzfG7LBEpBgr0MGRmPPzQQyyPT+D81dvIaN2LnTHJfpc
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"needs_background": "light"
|
|
|
|
|
},
|
|
|
|
|
"output_type": "display_data"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"poly = getClipThroughArea(\n",
|
|
|
|
|
" # 水平速度 horizontal speed\n",
|
|
|
|
|
" vh = array([0, 0, -50]),\n",
|
|
|
|
|
" # 鉛直速度 vertical speed\n",
|
|
|
|
|
" vy = -75,\n",
|
|
|
|
|
" # 境界上の一点 a point on the border\n",
|
|
|
|
|
" B = tri[1],\n",
|
|
|
|
|
" # 境界の法線ベクトル normal vector of the border\n",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
" # -(n.x, 0, n.z); n = cross(P1-P0, P2-P1) in game\n",
|
|
|
|
|
" nB = np.cross(tri[0]-tri[1], tri[2]-tri[1])*(1, 0, 1),\n",
|
2022-02-04 20:24:40 +09:00
|
|
|
|
" # すり抜ける地面の高さ\n",
|
|
|
|
|
" # height of the triangle that Mario clips through\n",
|
|
|
|
|
" yB = tri[1][1],\n",
|
|
|
|
|
")\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# x=0のときの断面図を描画。図の横軸をz軸(2)、縦軸をy軸(1)とする\n",
|
|
|
|
|
"# plot the cross section when x = 0\n",
|
|
|
|
|
"# use z(2) as horizontal axis and y(1) as vertical axis\n",
|
|
|
|
|
"fig, ax = Polygon(poly.slicePlane((0, 0, 0), (1, 0, 0))).plot(axis=(2, 1))\n",
|
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "6ed1e86e-e805-4be4-acde-0446cdf4063c",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"生成した図に関して、matplotlibで色々設定できます。 \n",
|
|
|
|
|
"You can configure the generated plot with matplotlib."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"execution_count": 25,
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"id": "0b64860d-b36b-4b5c-bb03-3e00daca9014",
|
|
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HEhFJaWpcNcDMuPP2O7h+wCV812sI275bHXUkEZGUlbDGZWZtzGyOmX1kZkvMbHA4fqSZfWBmi81shpm1LLPckWZWZGa9Ysa1DeddGq6v3XbqnmNmbma5MeOGmtnnZvaJmZ2SgM2tlFtvHsbNV17Dst5D2PbvFVHFEBFJaYnc4yoCrnf3jsDRwFVm1hG4190PcffDgGnA8NIFzCwNGA3MKLOup8LlDgSOAlaVV9DMdgUGA4tixnUE+gCdgFOBh8M6kbjphhu447rfsaz3ULZ+tSyqGCIiKSthjcvdl7v7e+HwJmAp0MrdN8bM1hCI/c6pq4HniWlMYeNJd/eZ4boK3H1LBWVHEjS+H2PG9QTy3H2ru/8L+Jyg+UXm2muu4e5hw1nWeyg/fv7vKKOIiKScGvmuwvDQ3jzgIHffaGajgAuBDUBXd19tZq2ACUBX4DFgmrtPNrOzgEuAbUB7YBYwxN2Ly9ToDAxz93PMLB+4wd3fMbO/AAvd/ZlwvnHAa+4+uczyA4GBADk5OUfk5eVVuD0FBQVkZ2dX6zEBWLN2Lf/+7lsy27fC6mdWernmPzqr61u161eHMkRfXxmSo35tylC0aj1NSad1q1ZVXragoIAePXrUju8qNLNsgr2oa0v3ttx9GDDMzIYCg4DbgAeAm9y9xOwnD346cDxwOPANMAkYAIyLqVEPuC8cv1PcfQwwBoIv2a3oS3Rh+1+yW1VPP/MMV156BS2eHkGDTntXapnLlmzl0U5Zcam/s5Qh+vrKkBz1a1OGVXPm0q+4Gf369q3ysvn5+dWqXRUJbVxmlkHQtMa7e3nf/jgeeJWgceUCeWHTagacbmZFwLfAYnf/MlznFIJzZuNi1rMrcBCQHy6/JzDVzH4
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"<Figure size 432x432 with 1 Axes>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"needs_background": "light"
|
|
|
|
|
},
|
|
|
|
|
"output_type": "display_data"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"fig, ax = Polygon(poly.slicePlane((0, 0, 0), (1, 0, 0))[:,[2,1]]).plot()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# 図のサイズを設定 resize figure\n",
|
|
|
|
|
"fig.set_size_inches(6, 6)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# タイトルを設定\n",
|
|
|
|
|
"ax.set_title('SB Pipe (vy=-75, vz=-50)')\n",
|
|
|
|
|
"# x軸のラベルを設定\n",
|
|
|
|
|
"ax.set_xlabel('z')\n",
|
|
|
|
|
"# y軸のラベルを設定\n",
|
|
|
|
|
"ax.set_ylabel('y')\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# 0.05刻みにする\n",
|
|
|
|
|
"# set tick interval to 0.05\n",
|
|
|
|
|
"ax.xaxis.set_major_locator(plticker.MultipleLocator(base=0.05))\n",
|
|
|
|
|
"ax.yaxis.set_major_locator(plticker.MultipleLocator(base=0.05))\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# ラベルのフォーマットを設定(xは目盛の値、iは番号)\n",
|
|
|
|
|
"# set the format of the labels\n",
|
|
|
|
|
"# (x is the value of the tick, and i is the index)\n",
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"ax.xaxis.set_major_formatter(plticker.FormatStrFormatter('%.2f'))\n",
|
|
|
|
|
"ax.yaxis.set_major_formatter(plticker.FormatStrFormatter('%.2f'))\n",
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"\n",
|
|
|
|
|
"# x軸のラベルを30度回転\n",
|
|
|
|
|
"# rotate x label 30 deg\n",
|
|
|
|
|
"ax.xaxis.set_tick_params(rotation=30)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# グリッドを表示 show grid\n",
|
|
|
|
|
"ax.grid()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
2022-03-11 21:31:38 +09:00
|
|
|
|
"id": "9163f1a0-9c6b-45ea-a856-ba98a6c9303c",
|
2022-02-04 20:24:40 +09:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": []
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "335e87c1-0a22-4b1c-8161-c684c3dd7105",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## 付録:本ライブラリによる図の描画 <br> Appendix: Plot with this library"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "19d9404c-fead-4a44-a188-6a62da53b932",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"毎回`fig.set_size_inches`でサイズを設定する代わりに、次の命令で図のデフォルトサイズを設定することができます。 \n",
|
|
|
|
|
"Instead of using `fig.set_size_inches` every time,\n",
|
|
|
|
|
"you can use the following instruction to set the default figure size."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "38910dd9-8393-48e9-8856-9d38ce8ef7e0",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"plt.rcParams[\"figure.figsize\"] = (5, 5)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "3cb0f6a6-9feb-457e-a093-7ccda1f36f7b",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"### 多角形 Polygon"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "6253eec4-a591-48b5-a4be-e791c14273ae",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"例として、ある正七角形といくつかの半平面との共通部分の描画方法を示します。 \n",
|
|
|
|
|
"As an example, I will demonstrate how to draw the intersection polygon\n",
|
|
|
|
|
"of a regular heptagon (7-gon) and some half planes."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 10,
|
|
|
|
|
"id": "7456018c-e8af-4ee7-b23c-4b7699d550f8",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVgAAAFNCAYAAABFd3doAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAA02ElEQVR4nO3dd3hUVf7H8fd3Jj0DCR2pQYUgSBVBFFj7ChZsq1ixoq4NV/2tvSAgCoQuiIBgRUUFlI5gWykGBZKACKJSFiRACgkhpJzfHzOwERNImzlTvq/nmYfJzCX3k9H55HLnnHvEGINSSqnq57AdQCmlgpUWrFJKeYkWrFJKeYkWrFJKeYkWrFJKeYkWrFJKeYkWrFJKeYkWrApoIpJzzK1IRMbZzqUUQJjtAEpVhTHGdeS+iLiA3cBH9hIp9T96BKuCyTXAHuCbsjYQkc4i8qOIHBCRj0TkAxEZXOL5u0Vki4jsF5G5ItKoxHNGRO4Vkc0ikikiE0REvPsjqUCmBauCSX/gLVPG/G8RiQA+BaYDtYH3gatKPH8+8DJwHXAS8Dsw85hvcxlwJtDes93fq/UnUEFFC1YFBRFpDvwNmHGczc7CfVpsrDGmwBjzCbC6xPM3AdOMMT8YY/KBJ4HuIpJQYpthxphMY8w2YDnQsRp/DBVktGBVsLgF+NYY8+uRB0RkQYkPv24CGgE7jznC3V7ifiPcR60AGGNygH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zZs2qKZ3/KS4u5pqbbyT/iu7UnTlYh0+paiVhTuo83I/o88/ggYef5cM5n/LmpMk6OaGSrJ5oEZFw3OX6rjHmk1I22Qk0LfF1E89jf2GMmWyM6WK
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"<Figure size 360x360 with 1 Axes>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"needs_background": "light"
|
|
|
|
|
},
|
|
|
|
|
"output_type": "display_data"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"# (1.5, 0.5)を中心とし、外接円半径2、-0.4 radだけ回転した正七角形\n",
|
|
|
|
|
"# A heptagon with center (1, 0.5), circumradius 2, rotated 0.05 rad\n",
|
|
|
|
|
"poly0 = Polygon(array([\n",
|
|
|
|
|
" [f(tau/7*i-0.4) for f in (np.cos, np.sin)]\n",
|
|
|
|
|
" for i in range(7)\n",
|
|
|
|
|
"])*2+(1.5, 0.5))\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# 描画 plot\n",
|
|
|
|
|
"fig, ax = poly0.plot()\n",
|
|
|
|
|
"# 図のサイズを設定 resize figure\n",
|
|
|
|
|
"fig.set_size_inches(5, 5)\n",
|
|
|
|
|
"# タイトルを設定\n",
|
|
|
|
|
"ax.set_title('7-gon')\n",
|
|
|
|
|
"# x軸のラベルを設定\n",
|
|
|
|
|
"ax.set_xlabel('x')\n",
|
|
|
|
|
"# y軸のラベルを設定\n",
|
|
|
|
|
"ax.set_ylabel('y')\n",
|
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 11,
|
|
|
|
|
"id": "81c98984-dbab-4111-8769-673c40c047e9",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSU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Z7UwylEtGuJtGtKWIcrdV9HVWZO7PqV1P4TaFGnAe/OmEWdOnVsR/IJ1maWxpgDwAHX7UwR2Q3UBr4/ZbGuwHxT1MwbRSRCRGq6nutTMjMzWbt27Z/7Ou799Tci2zRD2kYTOukZLrniYt3XUXlEcNOLqbN4HD9PWcgVLVswbuQoHvnHP/Qf5zLi1l2HRKQBcCWw6bSHagN7T/l9n+s+nyrLX375hRYxVxEWfQmOttGEDH2Yxi0u1X0dlTXi70fVZ+4l5KZrGPjcaN5d+BHvzZxN3bp1bUcrd9w2BRKRMGAR8Iwx5tgFvkZfEUkSkaSUlBR3RXObYWNGUblPF6oveJOoZ3oTGnOFFqXyCsFXXEzt2LH80rIOTa9syfQZM/DWjbe+yi1lKSL+FBXl+8aYT4tZJBk49Z+6Oq77/ocxZroxJsYYE+NtZ5I+fPgwH370EZUfvt12FKWKJf5+VH26FzUXDmPQlHFce1Mn/vjjD9uxyo1Sl6VrS/csYLcxZtwZFosFHpQi1wAZvra+cuJbk4m47Vr8oyJtR1HqrIIua0Dt2LH8FlOfpq2uZNo77+gs0w3csTW8A7AW+A4odN39b6AegDFmmqtQ3wJuoWjXoYeNMWfd1O1NW8Ozs7Op1aA+NT8dSWAj3eKofEfOj/8h9bmJXF6lBu/PmkP9+vVtR7LO5tbwdcBZN7+5toI/UdqxbJk9ezYhba7QolQ+J6hJA2p/Pob/vPMp0Ve1YuTrb9Dvscdw6B4b503fsXPIz89n2Lg
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"<Figure size 360x360 with 1 Axes>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"needs_background": "light"
|
|
|
|
|
},
|
|
|
|
|
"output_type": "display_data"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"# x+y>=1 との共通部分を取る\n",
|
|
|
|
|
"# Take the intersection with x+y>=1\n",
|
|
|
|
|
"## P=(1, 0) n=(1, 1)\n",
|
|
|
|
|
"poly1 = poly0.clipLine((1, 0), (1, 1))\n",
|
|
|
|
|
"fig, ax = poly1.plot()\n",
|
|
|
|
|
"fig.set_size_inches(5, 5)\n",
|
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 12,
|
|
|
|
|
"id": "daad4079-a225-4665-84fc-cd84be429871",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUsAAAEvCAYAAADM0uPSAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAt60lEQVR4nO3dfZzM5f7H8ddn9v4m1s3K2ihFpyIUuU+60cE5h2503FSoDt3oRql0UCklKYVSUslNwhJCq7W3bqPo1C9SHXXqFMuuXcti7djd6/eH6Zw9WmvYmblmZj/Px2Mfzc5+d663ybx9v/Od63uJMQallFKVc9gOoJRSgUDLUiml3KBlqZRSbtCyVEopN2hZKqWUG7QslVLKDaG2A5xM3bp1zXnnnWc7hlIqyGzdunWfMSb+dH/Pb8vyvPPOY8uWLbZjKKWCjIj8fCa/p4fhSinlBi1LpZRyg5alUkq5QctSKaXcoGWplFJu0LJUSik3aFkqpZQbtCyVUsoNWpZKKeUGLUulAkB+fj66qoFdWpZK+aGcnBySkpK44+4hNLywCfUS6vPH3n8hLy/PdrRqS8tSKT+wf/9+li1bxr0PPsD5zS/m3KZNGP7uVFYnOIiaNoKLd3zI9gbRXNyqBevXr7cdt1ry2wtpKBXMCgsLWb9+PSnpaXySmc5P3/+TWm2a4+jYnOgX76XppU2Q0JD/+Z26T93FwY7N6XHzDTz6wEOM+fsoQkJCTjKC8jSp6vsgItIQmAOcD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hWREqAI6GcsTB16adpUIm/v7uthlVJnICQminqTH6FgURrtu3Rm5zffUr9+fWt5PHU2vP8pfv46xz9aZM327dv59rvvaNz
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"<Figure size 360x360 with 1 Axes>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"needs_background": "light"
|
|
|
|
|
},
|
|
|
|
|
"output_type": "display_data"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"# 更に -x+4y<=6 との共通部分を取る\n",
|
|
|
|
|
"# Also take the intersection with -x+4y<=6\n",
|
|
|
|
|
"## P=(-6, 0) n=-(-1, 4)\n",
|
|
|
|
|
"poly2 = poly1.clipLine((-6, 0), (1, -4))\n",
|
|
|
|
|
"fig, ax = poly2.plot()\n",
|
|
|
|
|
"fig.set_size_inches(5, 5)\n",
|
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "8b749f43-a34f-4834-8b08-40e1c3bcb610",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"### 多面体 Polyhedron\n",
|
|
|
|
|
"例として、立方体といくつかの半空間との共通部分の**断面図**と**等高線図**の描画方法を示します。 \n",
|
|
|
|
|
"As an example, I will demonstrate how to plot the **cross section** and\n",
|
|
|
|
|
"**contour map** of the intersection of a cube and some half-spaces."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 13,
|
|
|
|
|
"id": "26cf21b3-2d63-4667-953d-f443f09ac658",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"Polyhedron with 8 vertices and 12 edges:\n",
|
|
|
|
|
"[[[0 0 0]\n",
|
|
|
|
|
" [0 0 1]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0 0 0]\n",
|
|
|
|
|
" [1 0 0]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0 0 1]\n",
|
|
|
|
|
" [1 0 1]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0 1 1]\n",
|
|
|
|
|
" [1 1 1]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1 0 0]\n",
|
|
|
|
|
" [1 1 0]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1 0 1]\n",
|
|
|
|
|
" [1 1 1]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0 1 0]\n",
|
|
|
|
|
" [0 1 1]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1 1 0]\n",
|
|
|
|
|
" [1 1 1]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0 0 0]\n",
|
|
|
|
|
" [0 1 0]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1 0 0]\n",
|
|
|
|
|
" [1 0 1]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0 1 0]\n",
|
|
|
|
|
" [1 1 0]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0 0 1]\n",
|
|
|
|
|
" [0 1 1]]]"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"execution_count": 13,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"cube = Polyhedron([\n",
|
|
|
|
|
" (i>>2&1, i>>1&1, i&1) for i in range(8)\n",
|
|
|
|
|
"], list({\n",
|
|
|
|
|
" (i, j)\n",
|
|
|
|
|
" for i in range(8)\n",
|
|
|
|
|
" for j in (i^4, i^2, i^1)\n",
|
|
|
|
|
" if i < j\n",
|
|
|
|
|
"}))\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"cube"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 14,
|
|
|
|
|
"id": "ab435fc3-6818-498b-8abd-97a1bb6e0327",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"Polyhedron with 10 vertices and 15 edges:\n",
|
|
|
|
|
"[[[0. 0. 0. ]\n",
|
|
|
|
|
" [0. 0. 1. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0. 0. 0. ]\n",
|
|
|
|
|
" [1. 0. 0. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0. 0. 1. ]\n",
|
|
|
|
|
" [0.5 0. 1. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1. 0. 0. ]\n",
|
|
|
|
|
" [1. 1. 0. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0. 1. 0. ]\n",
|
|
|
|
|
" [0. 1. 0.5 ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1. 1. 0. ]\n",
|
|
|
|
|
" [1. 1. 0. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0. 0. 0. ]\n",
|
|
|
|
|
" [0. 1. 0. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1. 0. 0. ]\n",
|
|
|
|
|
" [1. 0. 0.75 ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0. 1. 0. ]\n",
|
|
|
|
|
" [1. 1. 0. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0. 0. 1. ]\n",
|
|
|
|
|
" [0. 0.33333333 1. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0. 1. 0.5 ]\n",
|
|
|
|
|
" [0. 0.33333333 1. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0. 0.33333333 1. ]\n",
|
|
|
|
|
" [0.5 0. 1. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[0.5 0. 1. ]\n",
|
|
|
|
|
" [1. 0. 0.75 ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1. 0. 0.75 ]\n",
|
|
|
|
|
" [1. 1. 0. ]]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
" [[1. 1. 0. ]\n",
|
|
|
|
|
" [0. 1. 0.5 ]]]"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"execution_count": 14,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"# 2x+3y+4z<=5 との共通部分\n",
|
|
|
|
|
"# Intersection with x+y+z<=2\n",
|
|
|
|
|
"## P=(1,1,0), n=-(2,3,4)\n",
|
|
|
|
|
"poly3 = cube.clipPlane((1,1,0), (-2,-3,-4))\n",
|
|
|
|
|
"poly3"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 15,
|
|
|
|
|
"id": "d3174a4e-0f45-4088-9c99-1f50e7591e35",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
|
|
|
|
"vertices:\n",
|
|
|
|
|
"[[1. 0.5 0. ]\n",
|
|
|
|
|
" [1. 0.5 0.375]\n",
|
|
|
|
|
" [0. 0.5 0.875]\n",
|
|
|
|
|
" [0. 0.5 0. ]]\n",
|
|
|
|
|
"\n"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUoAAAFNCAYAAABmLCa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qbFZV/Jb15M24Zfxu//PKL39FEQoaKUgCIrlmN+JsuJXnpvTy07m1S0o7n4Ycf1oKPCCpKKaJicj0SZ15HnewbGffg/TRp1ZLXX3/d71givlJRyiFVad2E+gvvYv9Vfeh/2VA6d+/GJ5984ncsEV+oKOWwzIyaPU8l+c3ZfNXheNqf3olLhg3lu+++8zuaSJlSUYqnqIoVqPOX8wismssb0btpnNmU2ybczp49e/yOJlImVJRSbDG1qhN/61AaLJ5O9tpVpKQdz6OPPqoFH4l4Kko5apUC9Ul84AZqPXA918++h8yTWrF8+XK/Y4kEjYpSSqxqVib1F01h78he9P3LEM44uwfr16/3O5ZIqVNRyjExM2qd05HkN2fzRZsAbTt15NIRw9m6davf0URKjYpSSkVUpYrEDe9DYOVclrkfaZzZlDsmTuTXX3/1O5rIMVNRSqmKqV2d+NuGkZQzjVnvvU4gvTFPPPEEBw8e9DuaSImpKCUoKjU8jrpzb6TGzDFcO+NummW1ZuXKlX7HEikRFaUEVdU2zTjupansGdaT3pdcyJnnns3nn3/udyyRo6KilKAzM2r17kTKijl81uo4sk7twLCRI9i2bZvf0USKRUUpZSYqtiJxI/oRWDmHxfu+p1GTDCZOmsTevXv9jiZyRCpKKXMxdWqSMOEykl6ayv1vLSWQkca8efO04CMhS0UpvqnUKIm6D95E9XtHc9XUiZzQrg25ubl+xxL5HypK8V3Vds05LmcqP/35TM4dPJDu5/Xiyy+/9DuWyH+oKCUkWFQUtc87nZSVc/mkeSK
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"<Figure size 360x360 with 1 Axes>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"needs_background": "light"
|
|
|
|
|
},
|
|
|
|
|
"output_type": "display_data"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"# y=0.5の時の断面図\n",
|
|
|
|
|
"# Cross section when y=0.5\n",
|
|
|
|
|
"## P=(0,0.5,0), n=(0,1,0)\n",
|
|
|
|
|
"cs3 = poly3.slicePlane((0, 0.5, 0), (0, 1, 0))\n",
|
|
|
|
|
"print('vertices:', cs3, sep='\\n', end='\\n\\n')\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# only use coordinate of x and z axis (0, 2)\n",
|
|
|
|
|
"fig, ax = Polygon(cs3[:, [0, 2]]).plot()\n",
|
|
|
|
|
"fig.set_size_inches(5, 5)\n",
|
|
|
|
|
"ax.set_title('y = 0.5')\n",
|
|
|
|
|
"ax.set_xlabel('x')\n",
|
|
|
|
|
"ax.set_ylabel('z')\n",
|
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "dfb82844-c7a1-4cbd-a20c-6c92aaeba3c3",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"等高線図は、複数の断面図の合成とみなせます。 \n",
|
|
|
|
|
"Contour map can be seen as composition of several cross sections."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 16,
|
|
|
|
|
"id": "667bd35d-b3bd-4d52-a2de-144990e07377",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAFlCAYAAAD76RNtAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACWIElEQVR4nOydd3hT5fv/X0/S3VI6aUt30z3obsGB4ARZsjcqIDgQAWXvjYgLxYGKLAERkSWKyBAX3bulG2jL3hQKXef3R4Lw+3wFAYE+wbyuy+siyUmfO/H0fdJz7twvoSgKBgwYMGBA/1E1dAEGDBgwYODOYAh0A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fkExFoFBZHz7CLk/9KDyuNxD1xo1iUTz5Dp82+3g09WZZGZmMWXqDE6flnfomgF50btAr62tRZiqsGlVTHbH1mS1e5Rze/c2dFk3xCIggMAVy4hKSqC67giJz/hR/N4Yqk8ebejSrotQqXBo3YmoNUmYOrtR8dtCkiYFc+S3ZdTXStzNY9EYz44TiH+7hEbhcWRteorsLc9w/qjcEyks7UPweXwVZjaBLNtYioeXL2PGTuTECXmHrhmQD70LdND6KdxecyW+KBz79hXk9mxDxuMPcuaXXxq6tBtirtEQ8MVnRGekU29+kaSuQRS9NYLLR6WdNowQAiMrayJW/I7ftI85krqUpIkBHN79GfW18nZqqM2scH/6DeLeLsE2/jFyfuhM5sa2nD0k99A1lZEp3q2/JLhrMmu3n8DLx5/XRrzBkSPyDl0zIA96GehXUJmpaPqSC3GFzWjS5yT5gzqT3jKWU9u3S32e3czDA7+PPiQmJxv
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"<Figure size 432x432 with 1 Axes>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"needs_background": "light"
|
|
|
|
|
},
|
|
|
|
|
"output_type": "display_data"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"# y=0, 0.1, 0.2, ..., 1.0 とする\n",
|
|
|
|
|
"# Let y=0, 0.1, 0.2, ..., 1.0\n",
|
|
|
|
|
"ys = np.arange(11)/10\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# 各層の色\n",
|
|
|
|
|
"# Colors for each layer\n",
|
|
|
|
|
"colors = [\n",
|
|
|
|
|
" # red to yellow: 4\n",
|
|
|
|
|
" *('#FF%02X3F'%g for g in 0x3F+191*np.arange(4)//4),\n",
|
|
|
|
|
" # yellow to green: 1\n",
|
|
|
|
|
" *('#%02XFF3F'%r for r in 0xFF-191*np.arange(1)//1),\n",
|
|
|
|
|
" # green to cyan: 1\n",
|
|
|
|
|
" *('#3FFF%02X'%b for b in 0x3F+191*np.arange(1)//1),\n",
|
|
|
|
|
" # cyan to blue: 4\n",
|
|
|
|
|
" *('#3F%02XFF'%g for g in 0xFF-191*np.arange(4)//4),\n",
|
|
|
|
|
"][::-1] # reverse order\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# plot\n",
|
|
|
|
|
"fig, ax = contourMap(poly3, ys, colors)\n",
|
|
|
|
|
"fig.set_size_inches(6, 6)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# 0.1刻みにする\n",
|
|
|
|
|
"# set tick interval to 0.1\n",
|
|
|
|
|
"ax.xaxis.set_major_locator(plticker.MultipleLocator(base=0.1))\n",
|
|
|
|
|
"ax.yaxis.set_major_locator(plticker.MultipleLocator(base=0.1))\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# グリッドを表示\n",
|
|
|
|
|
"# show grid\n",
|
|
|
|
|
"ax.grid()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 17,
|
|
|
|
|
"id": "5dfbf5df-68ca-415b-b9a3-5667403904b1",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAFlCAYAAAD76RNtAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACoxUlEQVR4nOydZ1RUZ9eGrzMMvcPMgPSuIlaQosYSe++9p/fee+89b3piLzPYe+wmJhEULIiNoqCAytCk9/P9wOTNlzc5M4kocHKutVzLmbk9sxHO5pn97GffgiiKKCgoKCi0fVQtHYCCgoKCQvOgJHQFBQUFmaAkdAUFBQWZoCR0BQUFBZmgJHQFBQU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Sz8w7XuAO4A8PDwiNTr9c36xVwL5eXlODg4tHQYf0lLxFdfX0/K8VTsNV0QhL/+3S+KUFGQgm9AAMWNTtf8vo0NddSXF1FXXojY2ICljTuWNm6o1DbXdF03u3KKKlvn97ixvob6miJ0rmou5+ej1bjj7u6OpaVlS4f2/2jt9wnIP8YBAwYki6IY9WevNdem6GPAfwRBmAf8COQC/9PKIIri18DXAFFRUWL//v2b6e2vnX379tGa4vkjLRHfV199xUcLEgga9JCkrvjCHs4mLub9j95nRXn/5nlzC8AZys8f4/K2peQfWI61oy8eYXPQtZ+Gpa3mb19yRuQ+ViQ3U3zXiek99rFgvxfF6Usxpq+ic+eu3HXHHCZOnIijo2NLh9fq7xP4d8doTsklF/D93WOfq8/9hiiKeaIoThBFsTvw7NXnSporSIWW4btFepwCTB8mMqb
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"<Figure size 432x432 with 1 Axes>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"needs_background": "light"
|
|
|
|
|
},
|
|
|
|
|
"output_type": "display_data"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"# 更に 4x-y-z>=1 と 2x-y>=0.4 との共通部分を取る\n",
|
|
|
|
|
"# Also take the intersection with 4x-y-z>=1 and 2x-y>=0.4\n",
|
|
|
|
|
"poly4 = poly3.clipPlane((0, 0, -1), (4, -1, -1))\n",
|
|
|
|
|
"poly4 = poly4.clipPlane((0.2, 0, 0), (2, -1, 0))\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"fig, ax = contourMap(poly4, ys, colors)\n",
|
|
|
|
|
"fig.set_size_inches(6, 6)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# 0.1刻みにする\n",
|
|
|
|
|
"# set tick interval to 0.1\n",
|
|
|
|
|
"ax.xaxis.set_major_locator(plticker.MultipleLocator(base=0.1))\n",
|
|
|
|
|
"ax.yaxis.set_major_locator(plticker.MultipleLocator(base=0.1))\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# グリッドを表示\n",
|
|
|
|
|
"# show grid\n",
|
|
|
|
|
"ax.grid()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "a5222815-2553-46e7-a846-fb6d3c91d56c",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": []
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"id": "fb96d7a1-070a-4003-83f0-fb484d66603c",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## LICENSE"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "raw",
|
|
|
|
|
"id": "38626361-2823-4fd2-909e-200da839b233",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"Copyright (c) 2022 sup39[サポミク]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Permission is hereby granted, free of charge, to any person\n",
|
|
|
|
|
"obtaining a copy of this software and associated documentation\n",
|
|
|
|
|
"files (the \"Software\"), to deal in the Software without\n",
|
|
|
|
|
"restriction, including without limitation the rights to use,\n",
|
|
|
|
|
"copy, modify, merge, publish, distribute, sublicense, and/or sell\n",
|
|
|
|
|
"copies of the Software, and to permit persons to whom the\n",
|
|
|
|
|
"Software is furnished to do so, subject to the following\n",
|
|
|
|
|
"conditions:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"The above copyright notice and this permission notice shall be\n",
|
|
|
|
|
"included in all copies or substantial portions of the Software.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n",
|
|
|
|
|
"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n",
|
|
|
|
|
"OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n",
|
|
|
|
|
"NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n",
|
|
|
|
|
"HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n",
|
|
|
|
|
"WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n",
|
|
|
|
|
"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n",
|
|
|
|
|
"OTHER DEALINGS IN THE SOFTWARE."
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-03-11 21:31:38 +09:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "raw",
|
|
|
|
|
"id": "0412e7fe-ec24-43d4-bac0-ff42ab11bcd0",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"なおさん(@naosan_RTA2)が一部の数式を追加し、Formatterのバグを修正してくださいました。ありがとうございます!"
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-02-04 20:24:40 +09:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "71e144f3-6bff-4901-81b2-eb54c66576cc",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": []
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"metadata": {
|
|
|
|
|
"kernelspec": {
|
|
|
|
|
"display_name": "Python 3 (ipykernel)",
|
|
|
|
|
"language": "python",
|
|
|
|
|
"name": "python3"
|
|
|
|
|
},
|
|
|
|
|
"language_info": {
|
|
|
|
|
"codemirror_mode": {
|
|
|
|
|
"name": "ipython",
|
|
|
|
|
"version": 3
|
|
|
|
|
},
|
|
|
|
|
"file_extension": ".py",
|
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
|
"name": "python",
|
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
|
"version": "3.9.1"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"nbformat": 4,
|
|
|
|
|
"nbformat_minor": 5
|
|
|
|
|
}
|