ï¼ç¹éã®è·é¢ã®è¨ç®ã§ã¯å¹³æ¹æ ¹ãå¿
è¦ã«ãªãã¾ãããå¹³æ¹æ ¹ã¯å°ãéãè¨ç®ã§ããã¨ãããã¨ã§ãå¹³æ¹æ ¹ã使ãããæãç®ã»å²ãç®ã»è¶³ãç®ã¨çµ¶å¯¾å¤ã»æ大ã»æå°ã ãã§è·é¢ãè¿ä¼¼ããæ¹æ³ã«ã¤ãã¦ã®è¨äºã翻訳ãã¦ã¿ã¾ããã
flipcode - Fast Approximate Distance Functions
(12:02 è£è¶³ï¼ããããä»ã®æ¨æºçãªCPUã§ããæå³ã¯ã»ã¨ãã©ãªãã¨æãã¾ããè¿ä¼¼ã®ã¢ããã¼ãã¨ãã¦é¢ç½ãã¨ãããããã®è©±ãZ80ã§ããã¾ããã)
è·é¢é¢æ°é«éè¿ä¼¼
by Rafael Baptista (27 June 2003)
ï¼ç¹éã®ã¦ã¼ã¯ãªããè·é¢ãæ±ããè¨ç®å¼ã¯æ¬¡ã®ããã«ãªãã
äºæ¬¡å
ã§ã¯æ¬¡ã®ããã«ãªãã
ãã®é¢æ°ã®è¨ç®ã«ã¯ãå¹³æ¹æ ¹ãå¿ è¦ã«ãªããããã¯æè¿ã®ã³ã³ãã¥ã¼ã¿ã§ãé«ä¾¡ãªè¨ç®ã§ãããå¹³æ¹æ ¹ã¯é次è¿ä¼¼ã«ãã£ã¦æ±ãããããã¤ã¾ããã³ã³ãã¥ã¼ã¿ã¯å¹³æ¹æ ¹è¿ä¼¼ã®ã«ã¼ããè¡ã£ã¦ãä¸ãããã許容誤差ã«åã¾ãã¾ã§ç¹°ãè¿ããããããã£ã¨å¶ç´ã®å¤ããã¼ãã¦ã§ã¢ã§ä½æ¥ãã¦ãã¦ããã¼ãã¦ã§ã¢ã§ã®å¹³æ¹æ ¹å®è£ ããªããã°ãå°ããæ°ã®å¹³æ¹æ ¹ã®è¨ç®ã§ãããç¦æ¢ãããã ããã
å¤ãã®è¨ç®ã§ãäºä¹è·é¢ã§ã®æ¯è¼ãå¯è½ã§ãå¹³æ¹æ ¹ãã¾ã£ãã使ããªãããã«ã§ãããä¾ãã°ãå¿ è¦ãªè¨ç®ãè·é¢ã®æ¯è¼ã ãã ã¨èãããããªããäºä¹è·é¢ã§ã®è¨ç®ã¯ç価ã§ãããããããªãããæ¬å½ã«è·é¢ãæ±ããªãã¨ãããªãè¨ç®ããããããã¦ã¿ãã¨ããã¯ãã«ã®æ£è¦åã ã¨ããçé¢ã®ãã¦ã³ãã£ã³ã°ããªã¥ã¼ã ã使ã£ãè¡çªã·ã¹ãã ã®å®è£ ã ã¨ãã
ãããã®å ´åã«ãæ¨æºçãªè·é¢é¢æ°ãè¨ç®ããä½è£ããªãã¨ãã¦ãè·é¢é¢æ°ã®ã¡ãã£ã¨ããè¿ä¼¼ããã¦ãè¨ç®ã®ç°¡åãªç·å½¢æ¼ç®ã ãã§æ§æãããé¢æ°ã¯ã©ã¹ããããçè«ä¸ã¯ãã£ã¨æ¼ç®ã追å ãããã¨ã§ãç·å½¢è¿ä¼¼ãä¿ã£ãã¾ã¾ä»»æã®ç²¾åº¦ã§éç·å½¢é¢æ°ãè¨ç®ã§ãããå®éããã¯ãã³ã³ãã¥ã¼ã¿ã§å®è£ ãããã¨ãã«å¹³æ¹æ ¹é¢æ°ãè¡ããã¨ã¨ä¼¼ã¦ããªãããã§ã¯ãªããããã§è¿°ã¹ããã¨ãã¦ããé¢æ°ã¯ãæ¦ãã¦è·é¢ã2.5%ã®å¹³å誤差ã§è¿ä¼¼ããå°ãªãç·å½¢è¨ç®ã®å ´åã§ã ãããæ大5%ã®èª¤å·®ãããããã®ããå®è¡ãé常ã«é«éã§ãããæ大誤差ã¨å¹³å誤差ã®ãã¬ã¼ããªãã®èª¿æ´ã¯å¯è½ã§ãããã¦èª¤å·®ãé©åãªå¤ã«ãã£ã¦ããããã«é¢æ°ãæ§æãããã¨ãå¯è½ã§ããã
æåã«ãæ£ããè·é¢é¢æ°ã®3Dã°ã©ããè¦ã¦ã¿ããããã®3Dã°ã©ãã¯xã¨yã§-1ãã1ã¾ã§ã®ç¯å²ã®ã¦ã¼ã¯ãªããè·é¢ããããããã°ã©ãã®é«ãã¯è² ã®è·é¢ã表ããxã¨yã0ã®ã¨ããè·é¢ã¯0ã§ãããåéã®é ä¸ã«ãªããxã¨yã®å¤ãå¢ããã¨ãããã«å¿ãã¦åéã®ç¹ã¯ä¸ãã£ã¦ããããã®ã°ã©ãã®æé¢ã¯åã®ããã«ãªãã
ããã«ãxã¨yã®çµ¶å¯¾å¤ã®æ大ã¨æå°ã®ãxã¨yã®ç¯å²ã-1ãã1ã¾ã§ã®ã°ã©ãããããæ大ã®ã°ã©ãã¯4é¢ã®ãã©ãããã«ãªããxã¨yã0ã«ãªãç¹ã¯ããã®ãã©ãããã®é ç¹ã«ãªãããã®æé¢ã¯æ£æ¹å½¢ã«ãªãã
æå°å¤ã®ã°ã©ãã¯ãã©ãããã¨ã¯éã®æä½ã«ãªããã¨ããããããã®æé¢ã¯ååã«ãªãã
ãã®çµæããã®ãµãã¤ã®é¢æ°ã®ç·å½¢åæãè¡ãã¨ãè·é¢é¢æ°ã¸ã®ã¡ãã£ã¨ããè¿ä¼¼ãå¾ããã¨ãã§ããã æ大ã¨æå°ã®ç°ãªã£ãæ¯çã®å¤ã¯ç°ãªãå±æ§ã®è¿ä¼¼ãçæãããããã«æãããã®ã¯ãæ大誤差ãæããããã«èª¿æ´ãã¦ããããã®é¢æ°ãå¹³å誤差ãæå°ã«ãªãããããããã¯å¹³åäºä¹èª¤å·®ãæå°ã«ãªãããã«èª¿æ´ãããã¨ãã§ãããæ大誤差ã«ãªãã®ã¯xã¨yã0ã«è¿ã¥ãã¨ããã§ãããã¨ãããããããã¦ããããã¯æé¢ã®å½¢ãçæ³åãããã£ã¨ãã¯ãããå ´æã§ããã (æ¯çã®é
ã調æ´ãããã¨ã§ããã®ç¹ã§ã®èª¤å·®ãã¼ãã«æ¸ãããã¨ã¯å¯è½ã§ãããããããã»ãã®å ´æã§ã®ç²¾åº¦ã大ããç ç²ã«ãã)
ãããã®ç¹ã§ã®èª¤å·®ãè£æ£ããããç¹å¥ã«è¨è¨ããé
ã追å ãããã¨ã§ããã®é¢æ°ã®ç²¾åº¦ãããããã¨ãã§ããããã®å ´åãxãyããã大ããã¨ãããxã¨yã®å°ããã»ãã®16åã«ãªãã¨ããã ãã§é¢æ°ã®æ¯çãå¤ããã°ããããã®æ°ããé¢æ°ã®ã°ã©ãã«ã¯ãxãyã0ã«è¿ã¥ãã¨ããã«ã®ã¶ã®ã¶ãããã§ãããã£ã¦ãããã¨ãè¦ããã¨ãã§ãããç®çã«ãã£ã誤差ã«ãªãã¾ã§ãå¦çãç¹°ãè¿ãã¦ç·èª¤å·®ãæ¸ãããã¨ãã§ããããã¡ãããç·å½¢ã®é
ã追å ããã¨ãé¢æ°ã®è¨ç®ã¯ããé«ä¾¡ã«ãªãã
è¨ç®ããããxã¨yã®çµ¶å¯¾å¤ã®æ大ã¨æå°ãä¼´ã£ãè·é¢é¢æ°ã®è¿ä¼¼ã証æãããã¨ã¯ç°¡åã ãæ£ããè·é¢é¢æ°ãèããã¨ãä¸ããããã©ããªè·é¢Xã«ã¤ãã¦ãåå¾Xã®åãå¾ããæ¬è³ªçã«ã¯åã®ã°ã©ããç´ç·ã§è¿ä¼¼ãããã¨ã試ããxã¨yã®çµ¶å¯¾å¤ãåãã®ã¯ãè·é¢é¢æ°ã®çµæãå¤ããªããã¨ã«æ³¨æãããæåã«xã¨yã®çµ¶å¯¾å¤ãæåã«åããã¨ã§ãåé¡ãåã®ã²ã¨ã¤ã®è±¡éã ãã®è¿ä¼¼ã«æ¸ãããã¨ãã§ããããããããèããã¨ãxã¨yã®æ大æå°ãã¨ããã¨ã§ãåé¡ãï¼ååã ãã«éå®ã§ãããããã¯ãã¡ãã£ã¨ããè¿ä¼¼ãå°æ°ã®ç´ç·ã ãã§å¾ãã®ã«ååå°ãã弧ã§ããã
ãããã®é¢æ°ã¯é常ã«ç°¡åã«è¨ç®ã§ããæè¿ã®ãã¼ãã¦ã§ã¢ã§ã¯å®æ°æéã§è¨ç®ãããã¨ãã§ãããä»å使ã£ãä¿æ°ã¯1024ã®åæ°ã¨ãã¦è¡¨ãããã¨ã«æ³¨æãããããã¯ãã®é¢æ°ãæ´æ°ã¬ã¸ã¹ã¿ã¨å°ãã®æãç®ã ãã使ã£ã¦å®è£ ããã§ãããã¨ãæå³ããæçµçã«ã·ããã使ãã ãã§çµæãã¹ã±ã¼ã«ãã¦ã³ã§ããã2ã®ä¹æ°ã«ãªãåæ¯ã使ã£ãä¿æ°ãé¸ã¹ã°ããããå¯è½ã«ãªããã©ãã ãå¤ãã®ãããã使ããã¯ãã¬ã¸ã¹ã¿ãµã¤ãºã¨å¿ è¦ãªç²¾åº¦ã«ä¾åããã
ããã¯ã²ã¨ã¤ã®è¿ä¼¼é¢æ°ã®å®è£ ä¾ã§ããã
u32 approx_distance( s32 dx, s32 dy ) { u32 min, max, approx; if ( dx < 0 ) dx = -dx; if ( dy < 0 ) dy = -dy; if ( dx < dy ) { min = dx; max = dy; } else { min = dy; max = dx; } approx = ( max * 1007 ) + ( min * 441 ); if ( max < ( min << 4 )) approx -= ( max * 40 ); // add 512 for proper rounding return (( approx + 512 ) >> 10 ); }
ãã®è¿ä¼¼ã¯ããã¼ãã¦ã§ã¢ãå¶éããã¦ããã®ã§ããã°ãæãç®ãã使ããã«å®è£
ãããã¨ãå¯è½ã§ããã
u32 approx_distance( s32 dx, s32 dy ) { u32 min, max; if ( dx < 0 ) dx = -dx; if ( dy < 0 ) dy = -dy; if ( dx < dy ) { min = dx; max = dy; } else { min = dy; max = dx; } // coefficients equivalent to ( 123/128 * max ) and ( 51/128 * min ) return ((( max << 8 ) + ( max << 3 ) - ( max << 4 ) - ( max << 1 ) + ( min << 7 ) - ( min << 5 ) + ( min << 3 ) - ( min << 1 )) >> 8 ); }
(翻訳ããã¾ã§)
åèª
åæã§åºã¦ããåèªã«ã¤ãã¦
cross section | æé¢ |
ideal | çæ³ã® |
diviate | åºæºããã¯ããã |
quadrant | 象é |
demonstrate | 証æ |
constrain | å¶é |
coefficient | ä¿æ° |
denominator | åæ¯ |
åèã«ãªãæ¬
ãããã£ããå®æ°å¤ãæ±ãããããªè¨ç®ãæ°å¤è¨ç®ã ã¨ãæ°å¤è§£æã¨ãããã©ãæ©æ¢°å¦ç¿ã¨ããããã¨æãã¨ç¥ã£ã¦ããå¿
è¦ãããã
æ°å¤è¨ç®ã®å
¥éã¨ãã¦ã¯ãã®æ¬ãããããã
æ±ãç¯å²ããã¼ã£ã¦ãã£ã¦ãèªã¿ããããä¾ã¯BASICã ãã©ããªãã¨ãªããããã¨æãã
æ°å¤è¨ç®ã®ã¯ãªãâãã½ã³ã³ã使ã£ã¦è§£ãã
- ä½è : 鷹尾æ´ä¿
- åºç社/ã¡ã¼ã«ã¼: æ¥ç§æé£åºç社
- çºå£²æ¥: 1998/10/01
- ã¡ãã£ã¢: åè¡æ¬
- ã¯ãªãã¯: 19å
- ãã®ååãå«ãããã° (4件) ãè¦ã
å
·ä½çãªè¨ç®ã®æ¹æ³ã¯ãå®çªã®ãã¥ã¼ã¡ãªã«ã«ã¬ã·ããã¾ãå¤ãã¦ããããæ¹å¤ããã£ã¦ãã°ããã£ã¦ãæ¬å½ã¯æ°ããçã®è¨³ãã»ããã¨ããã ãã©ãæå§ãã«ãæ¬æ°ã§ãããªãåèã®ææ°çã®ã»ããããã§ãã
- ä½è : William H. Press,William T. Vetterling,Saul A. Teukolsky,Brian P. Flannery,ä¸¹æ ¶åå¸,ä½è¤ä¿é,奥ææ´å½¦,å°æèª
- åºç社/ã¡ã¼ã«ã¼: æè¡è©è«ç¤¾
- çºå£²æ¥: 1993/06/01
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 2人 ã¯ãªãã¯: 102å
- ãã®ååãå«ãããã° (33件) ãè¦ã
ãã¨ããã¤ã©ã¼å±éã¨ãã¯ç¥ã£ã¦ããå¿
è¦ãããã®ã§ãç¡å°æ°å¦ã¬ã¼ã«ãªã©èªãã§ããã¨ããã¨æãã¾ãã
æ°å¦ã¬ã¼ã« (æ°å¦ã¬ã¼ã«ã·ãªã¼ãº 1)
- ä½è : çµå浩
- åºç社/ã¡ã¼ã«ã¼: SBã¯ãªã¨ã¤ãã£ã
- çºå£²æ¥: 2007/06/27
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 58人 ã¯ãªãã¯: 1,055å
- ãã®ååãå«ãããã° (967件) ãè¦ã