ðªé«ééå¹³æ¹æ ¹ãæ±ããããžãã¯ãã³ããŒããããŸããïŒ
ã¯ããé«ééå¹³æ¹æ ¹ïŒFast Inverse Square RootïŒãæ±ããããã®æåãªãããžãã¯ãã³ããŒãããããŸãããã®ã¢ã«ãŽãªãºã ã¯ãããšããšQuake III Arenaã®ãœãŒã¹ã³ãŒãã§ç¥ãããããã«ãªããŸããããã®æ¹æ³ã¯æµ®åå°æ°ç¹æ°ã®ãããè¡šçŸãå©çšããŠããããã®éã«äœ¿çšããããããžãã¯ãã³ããŒã㯠0x5f3759df ã§ãã
以äžããã®å žåçãªå®è£ äŸã§ãïŒCèšèªé¢šã®æ¬äŒŒã³ãŒãïŒïŒ
float Q_rsqrt(float number) {
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = *(long*)&y; // æµ®åå°æ°ç¹æ°ãæŽæ°ãšããŠè§£é
i = 0x5f3759df - (i >> 1); // ããžãã¯ãã³ããŒã䜿çš
y = *(float*)&i; // æŽæ°ãæµ®åå°æ°ç¹æ°ã«æ»ã
y = y * (threehalfs - (x2 * y * y)); // ãã¥ãŒãã³æ³ã®1åç®ã®å埩
return y;
}
ãã®ã¢ã«ãŽãªãºã ã¯ããã¥ãŒãã³æ³ãå©çšããå埩åŠçã«ãã£ãŠéå¹³æ¹æ ¹ãéåžžã«é«éã«è¿äŒŒããããšãã§ããŸãã 0x5f3759df ã¯ç¹å®ã®ããŒããŠã§ã¢ã¢ãŒããã¯ãã£ã«æé©åãããŠãããããæ±çšçãªçšéã§ã¯ä»ã®ææ³ãã©ã€ãã©ãªã䜿çšããæ¹ãè¯ãããšããããŸããããã®æ¹æ³ã¯æŽå²çã«éåžžã«æåã§ãã
æ°çã¢ãã«ãã¢ã«ãŽãªãºã ã«ãããŠããããŸããŸãªãããžãã¯ãã³ããŒãã䜿ãããŠãããç¹å®ã®ç®çã«æé©åãããããå¹çåãå®çŸããããã«æŽ»çšãããŠããŸãã以äžã«ãããã€ãã®ä»£è¡šçãªäŸãæããŸãã
Bresenhamã®ã¢ã«ãŽãªãºã
ã°ã©ãã£ãã¯ã¹ã«ãããçŽç·ãæç»ããéã«äœ¿ãããBresenhamã®ã¢ã«ãŽãªãºã ã§ã¯ãæŽæ°ã®é€ç®ãé¿ããããã«ãããžãã¯ãã³ããŒãã䜿ãããããšããããŸããããšãã°ãããç¹å®ã®ãªãã»ãããåæå€ãçµæãæé©åããããã«æåã§èª¿æŽãããå ŽåããããŸãã
ããã·ã¥é¢æ°ã®ããžãã¯ãã³ããŒ
ããã·ã¥é¢æ°ããã§ãã¯ãµã ã¢ã«ãŽãªãºã ïŒCRCãªã©ïŒã«ãããžãã¯ãã³ããŒãç»å ŽããŸããããšãã°ãMurmurHashãFNV-1aãªã©ã§ã¯ç¹å®ã®ãããžãã¯ãã©ã€ã ãã䜿çšãããŠãããããã«ããè¡çªçãäœæžããçµæã®åæ£æ§ãåäžããŸãã代衚çãªãã®ãšããŠä»¥äžããããŸãïŒ
MurmurHash3: 0x5bd1e995 ãšããå®æ°ã䜿ãããã
FNV-1a ããã·ã¥: FNV-1a ã§ã¯ 0x811C9DC5 ããªãã»ããããŒã¹ã0x01000193 ããã©ã€ã æ°ãšããŠäœ¿ãããŠããŸãã
Perlinãã€ãº
ãã€ãºçæã®ã¢ã«ãŽãªãºã ã§ããPerlinãã€ãºã§ããè£éãã°ã©ããŒã·ã§ã³èšç®ã§äœ¿çšããã5次ã®è£éé¢æ°ïŒ6t^5 - 15t^4 + 10t^3ïŒã¯ãç¹å®ã®è£éå質ãä¿ã€ããã«ããžãã¯ãã³ããŒçã«æ§æãããŠããŸãããã®åœ¢ã®è£éé¢æ°ã¯ãæ»ãããªãã€ãºçæã«é©ããŠãããšãããŠããŸãã
Zigguratã¢ã«ãŽãªãºã
ä¹±æ°çæã¢ã«ãŽãªãºã ã§ããZigguratã¢ã«ãŽãªãºã ã§ã¯ãææ°é¢æ°ãæ£èŠååžããã®ä¹±æ°ãå¹ççã«çæããããã«ãç¹å®ã®éŸå€ãå®æ°ïŒããžãã¯ãã³ããŒïŒã䜿çšãããŸããããšãã°ãããŒãã«ãäºåèšç®ããéã®å€ããç¹å®ã®ãè·³ãè¿ããç¯å²ãããžãã¯ãã³ããŒã®åœ¢ã§äºåã«æ±ºå®ãããŠããŸãã
Sin/Cosã®é«éè¿äŒŒ
äžè§é¢æ°ã®é«éè¿äŒŒã«ãããžãã¯ãã³ããŒã䜿ãããããšããããŸããç¹ã«å€ãã²ãŒã ããã°ã©ãã³ã°ã§ã¯ãããŒãã«ã«ãã¯ã¢ãããç¹å®ã®åŒã䜿ã£ãŠsinãcosãè¿äŒŒããéã«ãç¹å®ã®å®æ°ã䜿ãããŸãã
äŸãã°ãx * (Ï - x) / 2 ãªã©ã®åŒãäžè§é¢æ°ã®è¿äŒŒã«äœ¿ãããããšãããããããããæå³ã§ããžãã¯ãã³ããŒã掻çšããŠããŸãã
ã¡ã«ã»ã³ãã»ãã€ã¹ã¿
ä¹±æ°çæã¢ã«ãŽãªãºã ã®ä»£è¡šäŸã§ããã¡ã«ã»ã³ãã»ãã€ã¹ã¿ã§ã¯ãç¹å®ã®ãã©ã¡ãŒã¿ã§ãã19937ãšããæ°ãåšæé·ïŒ2^19937â1ïŒã決å®ããéèŠãªå®æ°ãšããŠäœ¿çšãããŠããŸãããŸããåæåãã¯ãã«ãä¿æ°ã«ãããžãã¯ãã³ããŒçãªå®æ°ãå«ãŸããŠããŸãã
Quakeã®æŽæ°å¹³æ¹æ ¹
å ã»ã©ã®é«ééå¹³æ¹æ ¹ãšåãããæŽæ°ã®å¹³æ¹æ ¹ãå¹ççã«æ±ããããã®ã¢ã«ãŽãªãºã ã§ã¯ãç¹å®ã®ãããã·ããããªãã»ãããããžãã¯ãã³ããŒã®åœ¢ã§äœ¿ãããããšããããŸããããšãã°ã2é²æ³ã§ã®æé©åã®ããã®ããããã¹ã¯ãã·ããéãå žåçã§ãã
ãããã®ããžãã¯ãã³ããŒã¯ãéåžžãå®éšãçè«çãªåæã«ãã£ãŠç¹å®ã®åé¡ã«å¯ŸããŠæé©åããããã®ã§ãããã®ãããããæå³ãè¬ãããŠããããã®ãå€ããå¹ççãªã¢ã«ãŽãªãºã ãèšç®ã«ãããŠéåžžã«éèŠãªåœ¹å²ãæãããŠããŸãã