{"id":867,"date":"2009-02-11T12:09:44","date_gmt":"2009-02-11T12:09:44","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=867"},"modified":"2017-01-29T10:14:42","modified_gmt":"2017-01-29T01:14:42","slug":"%ec%82%bc%ea%b0%81%ed%98%95-%ed%8f%b4%eb%a6%ac%ea%b3%a4%ea%b3%bc-%ed%8e%b8%ec%84%a0ray%ec%9d%98-%ea%b5%90%ec%b0%a8%ec%a0%90","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=867","title":{"rendered":"\uc0bc\uac01\ud615 \ud3f4\ub9ac\uace4\uacfc \ud3b8\uc120(Ray)\uc758 \uad50\ucc28\uc810"},"content":{"rendered":"<p>\uc774 \uae00\uc740 <a href=\"http:\/\/www.lighthouse3d.com\/opengl\/maths\/index.php?raytriint\">http:\/\/www.lighthouse3d.com\/opengl\/maths\/index.php?raytriint<\/a>\uc758 \uae00\uc744 \ud1b5\ud574 \uc7ac\uad6c\uc131\ud55c \uae00\ub85c, \ubcc0\uc5ed\ud558\uba74\uc11c \uc27d\uac8c \uc774\ud574\ud560 \uc218 \uc788\ub3c4\ub85d \ub0b4\uc6a9\uc744 \uc57d\uac04 \uc218\uc815\ud588\uc2b5\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/1\/1006786499.jpg\" alt=\"\uc0ac\uc6a9\uc790 \uc0bd\uc785 \uc774\ubbf8\uc9c0\" width=\"359\" height=\"265\" \/><br \/>\n\ub9e4\uac1c\ubcc0\uc218\ubc29\uc815\uc2dd\uc758 \ud615\ud0dc\ub85c \ud3b8\uc120(\uc2dc\uc791\uc810\uc5d0\uc11c \uc5b4\ub5a4 \ubc29\ud5a5\uc73c\ub85c \ubb34\ud55c\ud558\uac8c \uc9c4\ud589\ud558\ub294 \uc120, Ray)\uacfc \uc0bc\uac01\ud615\uc758 \ud3f4\ub9ac\uace4\uc774 \uc8fc\uc5b4\uc9c8\ub54c.. \uc774 \ub458\uc774 \uad50\ucc28\ud558\ub294\uac00\ub97c \ud310\ub2e8\ud558\ub294 \ubc29\ubc95\uc5d0 \ub300\ud574 \uc99d\uba85\uc740 \uc0dd\ub7b5\ud558\uace0 \uadf8 \ubc29\ubc95\uc5d0 \ub300\ud574\uc11c \uc54c\uc544 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uc0bc\uac01\ud615\uc744 \uad6c\uc131\ud558\ub294 \uc810\uc740 \ub2e4\uc74c\ucc98\ub7fc \uc815\uc758\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><div style=\"text-align: center;\"><strong>\uc0bc\uac01\ud615\uc758\u00a0 \uad6c\uc131 \uc810(u,v) = (1-u-v)*p0 + u*p1 + v*p2<br \/>\n\uc5ec\uae30\uc11c, p0, p1, p2\ub294 \uc0bc\uac01\ud615 \uc704\uc758 \uc774\ubbf8 \uc54c\uace0 \uc788\ub294 \uc810, u &gt;= 0, v &gt;= 0, u + v &lt;= 1.0<br \/>\n<\/strong><\/div>\n<\/p>\n<div style=\"text-align: center;\"><\/div>\n<p>\uadf8\ub9ac\uace0 \ud3b8\uc120\uc5d0 \ub300\ud55c \ub9e4\uac1c\ubcc0\uc218\ubc29\uc815\uc2dd\uc744 \ub2e4\uc74c\ucc98\ub7fc \uc815\uc758\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><div style=\"text-align: center;\"><strong>\ud3b8\uc120\uc758 \uad6c\uc131 \uc810(t) = p + t * d<br \/>\n\uc5ec\uae30\uc11c, p\ub294 \ud3b8\uc120\uc758 \uc2dc\uc791\uc810\uc73c\ub85c \uc774\ubbf8 \uc54c\uace0 \uc788\ub294 \uc810, d\ub294 \ud3b8\uc120\uc758 \ubc29\ud5a5 \ubca1\ud130<\/strong><\/div>\n<\/p>\n<div style=\"text-align: center;\"><\/div>\n<p>\uc774\uc81c \ud3b8\uc120\uacfc \uc0bc\uac01\ud615\uc758 \uad50\uc810\uc740 \uc0bc\uac01\ud615\uc758 \uad6c\uc131 \uc810(u,v) = \ud3b8\uc120\uc758 \uad6c\uc131 \uc810(t) \ub85c\ubd80\ud130 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><div style=\"text-align: center;\"><strong>p + t * d = (1-u-v) * p0 + u*p1 + v*p2<\/strong><\/div>\n<\/p>\n<p>\uacb0\uad6d&#8230; \uad50\ucc28 \uc5ec\ubd80\ub294 \uc138 \uac12(t, u, v)\uac00 \uc704\uc758 \uacf5\uc2dd\uc744 \ub9cc\uc871\ud558\uace0 u\uc640 v\uac00 \uc55e\uc11c \uc815\uc758\ud55c \uc870\uac74\uc744 \ub9cc\uc871\ud558\uba74 \uad50\ucc28\ud558\ub294 \uacbd\uc6b0\uc774\ub2e4. \uc774\ub7f0 \uc218\ud559\uc801\uc778 \ub17c\uc758\ub294 \ub2e4\uc74c\uc73c\ub85c \ubbf8\ub8e8\uae30\ub85c \ud558\uace0&#8230;. \uc5ec\ub7ec\ubd84\uc774 \uc6d0\ud558\ub294 C \ucf54\ub4dc\ub85c \ub300\uc2e0\ud569\ub2c8\ub2e4.<\/p>\n<pre>\/* a = b - c *\/\r\n#define vector(a,b,c) \\\r\n\u00a0 \u00a0 \u00a0 \u00a0 (a)[0] = (b)[0] - (c)[0]; \\\r\n\u00a0 \u00a0 \u00a0 \u00a0 (a)[1] = (b)[1] - (c)[1]; \\\r\n\u00a0 \u00a0 \u00a0 \u00a0 (a)[2] = (b)[2] - (c)[2];\r\n\r\nint rayIntersectsTriangle(float *p, float *d, float *v0, float *v1, float *v2) {\r\n\u00a0 \u00a0 float e1[3],e2[3],h[3],s[3],q[3];\r\n\u00a0 \u00a0 float a,f,u,v;\r\n\u00a0\r\n\u00a0 \u00a0 vector(e1,v1,v0);\r\n\u00a0 \u00a0 vector(e2,v2,v0);\r\n\u00a0 \u00a0 crossProduct(h,d,e2);\r\n\u00a0 \u00a0 a = innerProduct(e1,h);\r\n\u00a0\r\n\u00a0 \u00a0 if (a > -0.00001 && a < 0.00001) return(false);\r\n\u00a0\r\n\u00a0 \u00a0 f = 1\/a;\r\n\u00a0 \u00a0 vector(s,p,v0);\r\n\u00a0 \u00a0 u = f * (innerProduct(s,h));\r\n\u00a0\r\n\u00a0 \u00a0 if (u < 0.0 || u > 1.0) return (false);\r\n\u00a0\r\n\u00a0 \u00a0 crossProduct(q,s,e1);\r\n\u00a0 \u00a0 v = f * innerProduct(d,q);\r\n\u00a0 \u00a0 if (v < 0.0 || u + v > 1.0) return (false);\r\n\r\n\u00a0 \u00a0 \/\/ at this stage we can compute t to find out where \r\n\u00a0 \u00a0 \/\/ the intersection point is on the line\r\n\u00a0 \u00a0 t = f * innerProduct(e2,q);\r\n\u00a0 \u00a0 if (t > 0.00001) \/\/ ray intersection\r\n\u00a0 \u00a0 \u00a0 \u00a0 return (true);\r\n\u00a0 \u00a0 else \/\/ this means that there is line intersection but not ray intersection\r\n\u00a0 \u00a0 \u00a0 \u00a0 return (false);\r\n}<\/pre>\n<p>vector \ud568\uc218\ub294 \ub450\uac1c\uc758 \uc88c\ud45c\ub85c\ubd80\ud130 \ubc31\ud130\ub97c \ub9cc\ub4dc\ub294 \ud568\uc218\uc774\uace0 innerProduct\uc640 crossProduct\ub294 \ub0b4\uc801\uacfc \uc678\uc801\uc744 \uad6c\ud558\ub294 \ud568\uc218\uc785\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc774 \uae00\uc740 http:\/\/www.lighthouse3d.com\/opengl\/maths\/index.php?raytriint\uc758 \uae00\uc744 \ud1b5\ud574 \uc7ac\uad6c\uc131\ud55c \uae00\ub85c, \ubcc0\uc5ed\ud558\uba74\uc11c \uc27d\uac8c \uc774\ud574\ud560 \uc218 \uc788\ub3c4\ub85d \ub0b4\uc6a9\uc744 \uc57d\uac04 \uc218\uc815\ud588\uc2b5\ub2c8\ub2e4. \ub9e4\uac1c\ubcc0\uc218\ubc29\uc815\uc2dd\uc758 \ud615\ud0dc\ub85c \ud3b8\uc120(\uc2dc\uc791\uc810\uc5d0\uc11c \uc5b4\ub5a4 \ubc29\ud5a5\uc73c\ub85c \ubb34\ud55c\ud558\uac8c \uc9c4\ud589\ud558\ub294 \uc120, Ray)\uacfc \uc0bc\uac01\ud615\uc758 \ud3f4\ub9ac\uace4\uc774 \uc8fc\uc5b4\uc9c8\ub54c.. \uc774 \ub458\uc774 \uad50\ucc28\ud558\ub294\uac00\ub97c \ud310\ub2e8\ud558\ub294 \ubc29\ubc95\uc5d0 \ub300\ud574 \uc99d\uba85\uc740 \uc0dd\ub7b5\ud558\uace0 \uadf8 \ubc29\ubc95\uc5d0 \ub300\ud574\uc11c \uc54c\uc544 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \uc0bc\uac01\ud615\uc744 \uad6c\uc131\ud558\ub294 \uc810\uc740 \ub2e4\uc74c\ucc98\ub7fc \uc815\uc758\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc0bc\uac01\ud615\uc758\u00a0 \uad6c\uc131 \uc810(u,v) = (1-u-v)*p0 + u*p1 + &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=867\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\uc0bc\uac01\ud615 \ud3f4\ub9ac\uace4\uacfc \ud3b8\uc120(Ray)\uc758 \uad50\ucc28\uc810&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[39],"class_list":["post-867","post","type-post","status-publish","format-standard","hentry","category-algorithms","tag-algorithm"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=867"}],"version-history":[{"count":4,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/867\/revisions"}],"predecessor-version":[{"id":3456,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/867\/revisions\/3456"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=867"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}