{"id":1266,"date":"2017-08-27T20:17:08","date_gmt":"2017-08-27T11:17:08","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=1266"},"modified":"2020-10-25T18:22:21","modified_gmt":"2020-10-25T09:22:21","slug":"numpy%e5%85%a5%e9%96%80-%e8%a1%8c%e5%88%97%e3%81%ae%e8%a8%88%e7%ae%97-%e5%9b%9e%e8%bb%a2%e8%a1%8c%e5%88%97%e3%81%ae%e8%a8%88%e7%ae%97%e4%be%8b","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/1266","title":{"rendered":"NumPy\u5165\u9580 \u884c\u5217\u306e\u8a08\u7b97 \u56de\u8ee2\u884c\u5217\u306e\u8a08\u7b97\u4f8b"},"content":{"rendered":"<p>\u80a9\u6163\u3089\u3057\u3068\u3057\u3066\u4eca\u56de\u306f\u5177\u4f53\u7684\u304b\u3064\u7c21\u5358\u306a\u884c\u5217\u306e\u8a08\u7b97\u4f8b\u3068\u3057\u3066\u56de\u8ee2\u884c\u5217\u306b\u3088\u308b\u4e00\u6b21\u5909\u63db\u3092\u53d6\u308a\u4e0a\u3052\u3066\u307f\u307e\u3059\u3002<\/p>\n<h2>\u56de\u8ee2\u884c\u5217\u306b\u3088\u308b\u4e00\u6b21\u5909\u63db<\/h2>\n<p>\u5e73\u9762\u5ea7\u6a19\u4e0a\u306e\u59cb\u70b9(0, 1)\u306b\u5bfe\u3057\u3001\u56de\u8ee2\u884c\u5217\u306b\u3088\u308a30\u5ea6\u305a\u3064\u56de\u8ee2\u79fb\u52d5\u3055\u305b\u3066\u307f\u307e\u3059\u3002\u79fb\u52d5\u3055\u305b\u305f\u70b9\u3092matplotlib\u3067\u53ef\u8996\u5316\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>NumPy\u3067\u306f\u4e09\u89d2\u95a2\u6570\u306esin\u3001cos\u304cnp.sin\u3001np.cos\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u56de\u8ee2\u884c\u5217\u306e\u5404\u8981\u7d20\u3067\u305d\u308c\u3089\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u884c\u5217\u306e\u639b\u3051\u7b97\u3067\u306f<a href=\"http:\/\/www.python.ambitious-engineer.com\/archives\/1262\">\u524d\u56de<\/a>\u5b66\u7fd2\u3057\u305fnp.dot\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\n\r\ndef get_rotation_matrix(rad):\r\n    &quot;&quot;&quot;\r\n    \u6307\u5b9a\u3057\u305frad\u306e\u56de\u8ee2\u884c\u5217\u3092\u8fd4\u3059\r\n    &quot;&quot;&quot;\r\n    rot = np.array([[np.cos(rad), -np.sin(rad)],\r\n                    [np.sin(rad), np.cos(rad)]])\r\n    return rot\r\n\r\n\r\n# \u59cb\u70b9\r\nbase_point = np.array([1, 0])\r\nx_points = []\r\ny_points = []\r\n\r\nfor i in range(0, 12):\r\n    deg = i * 30\r\n    rad = deg * np.pi \/ 180\r\n    rot = get_rotation_matrix(rad)\r\n    rotated = np.dot(rot, base_point)\r\n    x_points.append(rotated[0])\r\n    y_points.append(rotated[1])\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(1, 1, 1)\r\nax.scatter(x_points, y_points)\r\nax.grid(True)\r\n\r\nplt.gca().set_aspect('equal', adjustable='box')\r\nplt.show()\r\n\r\n\r\n<\/pre>\n<p>\u4e0a\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b0\u30e9\u30d5\u304c\u63cf\u753b\u3055\u308c\u3001\u4e00\u6b21\u5909\u63db\u306b\u3088\u3063\u3066\u56de\u8ee2\u79fb\u52d5\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/08\/rotation_matrix.png\"><img loading=\"lazy\" src=\"http:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2017\/08\/rotation_matrix.png\" alt=\"\" width=\"640\" height=\"644\" class=\"alignnone size-full wp-image-1267\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80a9\u6163\u3089\u3057\u3068\u3057\u3066\u4eca\u56de\u306f\u5177\u4f53\u7684\u304b\u3064\u7c21\u5358\u306a\u884c\u5217\u306e\u8a08\u7b97\u4f8b\u3068\u3057\u3066\u56de\u8ee2\u884c\u5217\u306b\u3088\u308b\u4e00\u6b21\u5909\u63db\u3092\u53d6\u308a\u4e0a\u3052\u3066\u307f\u307e\u3059\u3002 \u56de\u8ee2\u884c\u5217\u306b\u3088\u308b\u4e00\u6b21\u5909\u63db \u5e73\u9762\u5ea7\u6a19\u4e0a\u306e\u59cb\u70b9(0, 1)\u306b\u5bfe\u3057\u3001\u56de\u8ee2\u884c\u5217\u306b\u3088\u308a30\u5ea6\u305a\u3064\u56de\u8ee2\u79fb\u52d5\u3055\u305b\u3066\u307f\u307e\u3059\u3002\u79fb\u52d5\u3055\u305b\u305f\u70b9\u3092m...<\/p>\n","protected":false},"author":1,"featured_media":3009,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[168],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1266"}],"collection":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/comments?post=1266"}],"version-history":[{"count":6,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1266\/revisions"}],"predecessor-version":[{"id":3505,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1266\/revisions\/3505"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/3009"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=1266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=1266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=1266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}