{"id":2169,"date":"2021-10-06T13:06:25","date_gmt":"2021-10-06T04:06:25","guid":{"rendered":"https:\/\/sirius10.net\/blog\/wordpress\/?p=2169"},"modified":"2021-10-06T13:06:28","modified_gmt":"2021-10-06T04:06:28","slug":"post-2169","status":"publish","type":"post","link":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/2021\/10\/06\/2169\/","title":{"rendered":"SDL2 \u3067\u6955\u5186\u3092\u56de\u8ee2\u3055\u305b\u308b"},"content":{"rendered":"\n<p>\u3000\u6955\u5186\u3092\u56de\u8ee2\u3057\u3066\u63cf\u753b\u3055\u305b\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/xy_oval.png\" alt=\"\" class=\"wp-image-2161\" srcset=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/xy_oval.png 320w, https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/xy_oval-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><figcaption>\u6955\u5186<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u3082\u3068\u3082\u3068\u3001\u4e0a\u306e\u3088\u3046\u306a\u6955\u5186\u3092\u56de\u8ee2\u3055\u305b\u307e\u3059\u3002\u4f8b\u3048\u3070\u300145\u00b0 \u56de\u8ee2\u3055\u305b\u305f\u4e0b\u306e\u3088\u3046\u306a\u6955\u5186\u3092\u63cf\u753b\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/rotate.png\" alt=\"\" class=\"wp-image-2170\" srcset=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/rotate.png 320w, https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/rotate-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><figcaption>45\u00b0\u56de\u8ee2\u3055\u305b\u305f\u6955\u5186<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u539f\u70b9\u3092\u4e2d\u5fc3\u3068\u3057\u3066\u3042\u308b\u70b9 (x, y) \u3092\u56de\u8ee2\u3055\u305b\u305f\u5ea7\u6a19 (x&#8217;, y&#8217;) \u3092\u6c42\u3081\u308b\u5f0f\u306f\u6b21\u306e\u5f0f\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"249\" height=\"65\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/rotate-1.png\" alt=\"\" class=\"wp-image-2171\"\/><figcaption>\u56de\u8ee2\u306e\u8a08\u7b97<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u3053\u306e\u8a08\u7b97\u3092\u884c\u3046\u95a2\u6570 rotate() \u3092\u4f5c\u308a\u307e\u3059\u3002\u5143\u306e\u5ea7\u6a19\u3092 SDL_Point \u3067\u53d7\u3051\u53d6\u308a\u3001\u65b0\u3057\u3044\u5ea7\u6a19\u306b\u5909\u66f4\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted file\">void rotate(SDL_Point *pt, int angle) {\n    int x, y;\n    double r;\n\n    x = pt-&gt;x, y = pt-&gt;y;\n    r = M_PI * angle \/ 180.;\n\n    pt-&gt;x = x * cos(r) - y * sin(r);\n    pt-&gt;y = x * sin(r) + y * cos(r);\n}<\/pre>\n\n\n\n<p>\u3000\u3053\u306e\u95a2\u6570\u3092\u4f7f\u3044\u3001draw_oval() \u95a2\u6570\u306b\u89d2\u5ea6\u306e\u5f15\u6570\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u76f4\u4ea4\u5ea7\u6a19\u306e xy \u5ea7\u6a19\u304c\u6c7a\u307e\u3063\u305f\u3089\u3001rotate() \u95a2\u6570\u3067\u56de\u8ee2\u5f8c\u306e\u5ea7\u6a19\u3092\u6c42\u3081\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted file\">void draw_oval(SDL_Renderer *renderer, int sx, int sy, int a, int b, int angle) \n{\n    SDL_Point p;\n    int x, y, px, py;\n\n    for( x = -a; x &lt;= a; x++ ) {\n        y = sqrt(1.0 - (double)(x*x)\/(a*a))*b +0.5;\n        p.x = x, p.y = y;\n        <span style=\"background-color: #ffff00\" class=\"background-color\">rotate(&amp;p, angle);<\/span>\n        px = sx + p.x;\n        py = sy - p.y;\n        SDL_RenderDrawPoint(renderer, px, py);\n        p.x = x, p.y = -y;\n        <span style=\"background-color: #ffff00\" class=\"background-color\">rotate(&amp;p, angle);<\/span>\n        px = sx + p.x;\n        py = sy - p.y;\n        SDL_RenderDrawPoint(renderer, px, py);\n    }\n    for( y = -b; y &lt;= b; y++ ) {\n        x = sqrt(1.0 - (double)(y*y)\/(b*b))*a +0.5;\n        p.x = x, p.y = y;\n        <span style=\"background-color: #ffff00\" class=\"background-color\">rotate(&amp;p, angle);<\/span>\n        px = sx + p.x;\n        py = sy - p.y;\n        SDL_RenderDrawPoint(renderer, px, py);\n        p.x = -x, p.y = y;\n        <span style=\"background-color: #ffff00\" class=\"background-color\">rotate(&amp;p, angle);<\/span>\n        px = sx + p.x;\n        py = sy - p.y;\n        SDL_RenderDrawPoint(renderer, px, py);\n    }\n}<\/pre>\n\n\n\n<p>\u3000\u3053\u308c\u3067\u4efb\u610f\u306e\u56de\u8ee2\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" src=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/rotate_oval.png\" alt=\"\" class=\"wp-image-2177\" srcset=\"https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/rotate_oval.png 320w, https:\/\/sirius10.net\/blog\/wordpress\/wp-content\/uploads\/2021\/10\/rotate_oval-300x225.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><figcaption>\u6955\u5186\u306e\u56de\u8ee2<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000\u306a\u304b\u306a\u304b\u304d\u308c\u3044\u306a\u56f3\u5f62\u304c\u304b\u3051\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u6955\u5186\u3092\u56de\u8ee2\u3057\u3066\u63cf\u753b\u3055\u305b\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u3000\u3082\u3068\u3082\u3068\u3001\u4e0a\u306e\u3088\u3046\u306a\u6955\u5186\u3092\u56de\u8ee2\u3055\u305b\u307e\u3059\u3002\u4f8b\u3048\u3070\u300145\u00b0 \u56de\u8ee2\u3055\u305b\u305f\u4e0b\u306e\u3088\u3046\u306a\u6955\u5186\u3092\u63cf\u753b\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002 \u3000\u539f\u70b9\u3092\u4e2d\u5fc3\u3068\u3057\u3066\u3042\u308b\u70b9 (x, y) \u3092\u56de\u8ee2\u3055\u305b\u305f\u5ea7\u6a19 (x&#038;#8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-2169","post","type-post","status-publish","format-standard","hentry","category-sdl2"],"_links":{"self":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=2169"}],"version-history":[{"count":6,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2169\/revisions"}],"predecessor-version":[{"id":2201,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/2169\/revisions\/2201"}],"wp:attachment":[{"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=2169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=2169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sirius10.net\/blog\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=2169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}